Version 16.112

This commit is contained in:
Antonio Cañas Vargas 2017-01-13 01:51:23 +01:00
parent e449d33b77
commit e327103aa9
173 changed files with 918 additions and 643 deletions

View File

@ -6,7 +6,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General 3 License as it under the terms of the GNU Affero General 3 License as

View File

@ -4,7 +4,7 @@
SWAD (Shared Workspace At a Distance), SWAD (Shared Workspace At a Distance),
is a web platform developed at the University of Granada (Spain), is a web platform developed at the University of Granada (Spain),
and used to support university teaching. and used to support university teaching.
Copyright (C) 1999-2016 Antonio Cañas-Vargas Copyright (C) 1999-2017 Antonio Cañas-Vargas
University of Granada (SPAIN) (acanas@ugr.es) University of Granada (SPAIN) (acanas@ugr.es)
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify

View File

@ -6,7 +6,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as

View File

@ -8,7 +8,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as

View File

@ -6,7 +6,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General 3 License as it under the terms of the GNU Affero General 3 License as

View File

@ -8,7 +8,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as

View File

@ -6,7 +6,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General 3 License as it under the terms of the GNU Affero General 3 License as

View File

@ -8,7 +8,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as

View File

@ -6,7 +6,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as

View File

@ -8,7 +8,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as

View File

@ -6,7 +6,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General 3 License as it under the terms of the GNU Affero General 3 License as
@ -559,7 +559,9 @@ bool Acc_CreateMyNewAccountAndLogIn (void)
Gbl.Usrs.Me.UsrDat.IDs.List = NULL; Gbl.Usrs.Me.UsrDat.IDs.List = NULL;
/***** Set password to the password typed by the user *****/ /***** Set password to the password typed by the user *****/
strcpy (Gbl.Usrs.Me.UsrDat.Password,NewEncryptedPassword); strncpy (Gbl.Usrs.Me.UsrDat.Password,NewEncryptedPassword,
Cry_LENGTH_ENCRYPTED_STR_SHA512_BASE64);
Gbl.Usrs.Me.UsrDat.Password[Cry_LENGTH_ENCRYPTED_STR_SHA512_BASE64] = '\0';
/***** User does not exist in the platform, so create him/her! *****/ /***** User does not exist in the platform, so create him/her! *****/
Acc_CreateNewUsr (&Gbl.Usrs.Me.UsrDat, Acc_CreateNewUsr (&Gbl.Usrs.Me.UsrDat,
@ -567,13 +569,17 @@ bool Acc_CreateMyNewAccountAndLogIn (void)
/***** Save nickname *****/ /***** Save nickname *****/
Nck_UpdateMyNick (NewNicknameWithoutArroba); Nck_UpdateMyNick (NewNicknameWithoutArroba);
strcpy (Gbl.Usrs.Me.UsrDat.Nickname,NewNicknameWithoutArroba); strncpy (Gbl.Usrs.Me.UsrDat.Nickname,NewNicknameWithoutArroba,
Nck_MAX_LENGTH_NICKNAME_WITHOUT_ARROBA);
Gbl.Usrs.Me.UsrDat.Nickname[Nck_MAX_LENGTH_NICKNAME_WITHOUT_ARROBA] = '\0';
/***** Save email *****/ /***** Save email *****/
if (Mai_UpdateEmailInDB (&Gbl.Usrs.Me.UsrDat,NewEmail)) if (Mai_UpdateEmailInDB (&Gbl.Usrs.Me.UsrDat,NewEmail))
{ {
/* Email updated sucessfully */ /* Email updated sucessfully */
strcpy (Gbl.Usrs.Me.UsrDat.Email,NewEmail); strncpy (Gbl.Usrs.Me.UsrDat.Email,NewEmail,Usr_MAX_BYTES_USR_EMAIL);
Gbl.Usrs.Me.UsrDat.Email[Usr_MAX_BYTES_USR_EMAIL] = '\0';
Gbl.Usrs.Me.UsrDat.EmailConfirmed = false; Gbl.Usrs.Me.UsrDat.EmailConfirmed = false;
} }

View File

@ -8,7 +8,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as

View File

@ -6,7 +6,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as

View File

@ -8,7 +8,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as

View File

@ -6,7 +6,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General 3 License as it under the terms of the GNU Affero General 3 License as
@ -947,10 +947,12 @@ static void Agd_GetDataOfEventByCod (struct AgendaEvent *AgdEvent)
Dat_PRESENT)); Dat_PRESENT));
/* Get the event (row[7]) */ /* Get the event (row[7]) */
strcpy (AgdEvent->Event,row[7]); strncpy (AgdEvent->Event,row[7],Agd_MAX_LENGTH_EVENT);
AgdEvent->Event[Agd_MAX_LENGTH_EVENT] = '\0';
/* Get the event (row[8]) */ /* Get the event (row[8]) */
strcpy (AgdEvent->Location,row[8]); strncpy (AgdEvent->Location,row[8],Agd_MAX_LENGTH_LOCATION);
AgdEvent->Location[Agd_MAX_LENGTH_LOCATION] = '\0';
} }
else else
{ {
@ -1007,7 +1009,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);
strcpy (Txt,row[0]); strncpy (Txt,row[0],Cns_MAX_BYTES_TEXT);
Txt[Cns_MAX_BYTES_TEXT] = '\0';
} }
else else
Txt[0] = '\0'; Txt[0] = '\0';

View File

@ -8,7 +8,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as
@ -34,8 +34,8 @@
/************************** Public types and constants ***********************/ /************************** Public types and constants ***********************/
/*****************************************************************************/ /*****************************************************************************/
#define Agd_MAX_LENGTH_LOCATION 255 #define Agd_MAX_LENGTH_LOCATION (256-1)
#define Agd_MAX_LENGTH_EVENT 255 #define Agd_MAX_LENGTH_EVENT (256-1)
#define Agd_NUM_DATES 2 #define Agd_NUM_DATES 2
typedef enum typedef enum

View File

@ -6,7 +6,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General 3 License as it under the terms of the GNU Affero General 3 License as

View File

@ -8,7 +8,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as

View File

@ -6,7 +6,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as
@ -79,7 +79,7 @@ static void Asg_PutFormsToRemEditOneAsg (long AsgCod,bool Hidden);
static void Asg_PutParams (void); static void Asg_PutParams (void);
static void Asg_GetDataOfAssignment (struct Assignment *Asg,const char *Query); static void Asg_GetDataOfAssignment (struct Assignment *Asg,const char *Query);
static void Asg_ResetAssignment (struct Assignment *Asg); static void Asg_ResetAssignment (struct Assignment *Asg);
static void Asg_GetAssignmentTxtFromDB (long AsgCod,char *Txt); static void Asg_GetAssignmentTxtFromDB (long AsgCod,char Txt[Cns_MAX_BYTES_TEXT + 1]);
static void Asg_PutParamAsgCod (long AsgCod); static void Asg_PutParamAsgCod (long AsgCod);
static bool Asg_CheckIfSimilarAssignmentExists (const char *Field,const char *Value,long AsgCod); static bool Asg_CheckIfSimilarAssignmentExists (const char *Field,const char *Value,long AsgCod);
static void Asg_ShowLstGrpsToEditAssignment (long AsgCod); static void Asg_ShowLstGrpsToEditAssignment (long AsgCod);
@ -434,8 +434,8 @@ static void Asg_WriteAsgAuthor (struct Assignment *Asg)
{ {
bool ShowPhoto = false; bool ShowPhoto = false;
char PhotoURL[PATH_MAX+1]; char PhotoURL[PATH_MAX+1];
char FirstName[Usr_MAX_BYTES_NAME+1]; char FirstName[Usr_MAX_BYTES_NAME + 1];
char Surnames[2*(Usr_MAX_BYTES_NAME+1)]; char Surnames[Usr_MAX_BYTES_SURNAMES + 1];
struct UsrData UsrDat; struct UsrData UsrDat;
/***** Initialize structure with user's data *****/ /***** Initialize structure with user's data *****/
@ -452,8 +452,12 @@ static void Asg_WriteAsgAuthor (struct Assignment *Asg)
"PHOTO15x20",Pho_ZOOM,false); "PHOTO15x20",Pho_ZOOM,false);
/***** Write name *****/ /***** Write name *****/
strcpy (FirstName,UsrDat.FirstName); strncpy (FirstName,UsrDat.FirstName,Usr_MAX_BYTES_NAME);
strcpy (Surnames,UsrDat.Surname1); UsrDat.FirstName[Usr_MAX_BYTES_NAME] = '\0';
strncpy (Surnames,UsrDat.Surname1,Usr_MAX_BYTES_SURNAMES);
Surnames[Usr_MAX_BYTES_SURNAMES] = '\0';
if (UsrDat.Surname2[0]) if (UsrDat.Surname2[0])
{ {
strcat (Surnames," "); strcat (Surnames," ");
@ -776,10 +780,13 @@ 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]) */
strcpy (Asg->Title,row[6]); strncpy (Asg->Title,row[6],Asg_MAX_LENGTH_ASSIGNMENT_TITLE);
Asg->Title[Asg_MAX_LENGTH_ASSIGNMENT_TITLE] = '\0';
/* Get the folder for the assignment files (row[7]) */ /* Get the folder for the assignment files (row[7]) */
strcpy (Asg->Folder,row[7]); strncpy (Asg->Folder,row[7],Asg_MAX_LENGTH_FOLDER);
Asg->Folder[Asg_MAX_LENGTH_FOLDER] = '\0';
Asg->SendWork = (Asg->Folder[0] != '\0'); Asg->SendWork = (Asg->Folder[0] != '\0');
/* Can I do this assignment? */ /* Can I do this assignment? */
@ -830,7 +837,7 @@ void Asg_FreeListAssignments (void)
/******************** Get assignment text from database **********************/ /******************** Get assignment text from database **********************/
/*****************************************************************************/ /*****************************************************************************/
static void Asg_GetAssignmentTxtFromDB (long AsgCod,char *Txt) static void Asg_GetAssignmentTxtFromDB (long AsgCod,char Txt[Cns_MAX_BYTES_TEXT + 1])
{ {
char Query[512]; char Query[512];
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
@ -848,7 +855,8 @@ static void Asg_GetAssignmentTxtFromDB (long AsgCod,char *Txt)
{ {
/* Get info text */ /* Get info text */
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
strcpy (Txt,row[0]); strncpy (Txt,row[0],Cns_MAX_BYTES_TEXT);
Txt[Cns_MAX_BYTES_TEXT] = '\0';
} }
else else
Txt[0] = '\0'; Txt[0] = '\0';
@ -865,7 +873,7 @@ static void Asg_GetAssignmentTxtFromDB (long AsgCod,char *Txt)
/*****************************************************************************/ /*****************************************************************************/
// This function may be called inside a web service // This function may be called inside a web service
void Asg_GetNotifAssignment (char *SummaryStr,char **ContentStr, void Asg_GetNotifAssignment (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],char **ContentStr,
long AsgCod,unsigned MaxChars,bool GetContent) long AsgCod,unsigned MaxChars,bool GetContent)
{ {
char Query[512]; char Query[512];
@ -887,16 +895,20 @@ void Asg_GetNotifAssignment (char *SummaryStr,char **ContentStr,
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
/***** Get summary *****/ /***** Get summary *****/
strcpy (SummaryStr,row[0]); strncpy (SummaryStr,row[0],Cns_MAX_BYTES_TEXT);
SummaryStr[Cns_MAX_BYTES_TEXT] = '\0';
if (MaxChars) if (MaxChars)
Str_LimitLengthHTMLStr (SummaryStr,MaxChars); Str_LimitLengthHTMLStr (SummaryStr,MaxChars);
/***** Get content *****/ /***** Get content *****/
if (GetContent) if (GetContent)
{ {
if ((*ContentStr = (char *) malloc (512+Cns_MAX_BYTES_TEXT)) == NULL) if ((*ContentStr = (char *) malloc (Cns_MAX_BYTES_TEXT + 1)) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for notification content."); Lay_ShowErrorAndExit ("Error allocating memory for notification content.");
strcpy (*ContentStr,row[1]);
strncpy (*ContentStr,row[1],Cns_MAX_BYTES_TEXT);
(*ContentStr)[Cns_MAX_BYTES_TEXT] = '\0';
} }
} }
mysql_free_result (mysql_res); mysql_free_result (mysql_res);

View File

@ -8,7 +8,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as
@ -34,7 +34,7 @@
/************************** Public types and constants ***********************/ /************************** Public types and constants ***********************/
/*****************************************************************************/ /*****************************************************************************/
#define Asg_MAX_LENGTH_ASSIGNMENT_TITLE 255 #define Asg_MAX_LENGTH_ASSIGNMENT_TITLE (256-1)
#define Asg_MAX_LENGTH_FOLDER 32 #define Asg_MAX_LENGTH_FOLDER 32
@ -75,7 +75,8 @@ void Asg_GetDataOfAssignmentByCod (struct Assignment *Asg);
void Asg_GetDataOfAssignmentByFolder (struct Assignment *Asg); void Asg_GetDataOfAssignmentByFolder (struct Assignment *Asg);
void Asg_FreeListAssignments (void); void Asg_FreeListAssignments (void);
void Asg_GetNotifAssignment (char *SummaryStr,char **ContentStr,long AsgCod,unsigned MaxChars,bool GetContent); void Asg_GetNotifAssignment (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],char **ContentStr,
long AsgCod,unsigned MaxChars,bool GetContent);
long Asg_GetParamAsgCod (void); long Asg_GetParamAsgCod (void);
void Asg_ReqRemAssignment (void); void Asg_ReqRemAssignment (void);

View File

@ -6,7 +6,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as
@ -89,7 +89,7 @@ static void Att_PutParams (void);
static void Att_GetListAttEvents (Att_OrderTime_t Order); static void Att_GetListAttEvents (Att_OrderTime_t Order);
static void Att_GetDataOfAttEventByCodAndCheckCrs (struct AttendanceEvent *Att); static void Att_GetDataOfAttEventByCodAndCheckCrs (struct AttendanceEvent *Att);
static void Att_ResetAttendanceEvent (struct AttendanceEvent *Att); static void Att_ResetAttendanceEvent (struct AttendanceEvent *Att);
static void Att_GetAttEventTxtFromDB (long AttCod,char *Txt); static void Att_GetAttEventTxtFromDB (long AttCod,char Txt[Cns_MAX_BYTES_TEXT + 1]);
static bool Att_CheckIfSimilarAttEventExists (const char *Field,const char *Value,long AttCod); static bool Att_CheckIfSimilarAttEventExists (const char *Field,const char *Value,long AttCod);
static void Att_ShowLstGrpsToEditAttEvent (long AttCod); static void Att_ShowLstGrpsToEditAttEvent (long AttCod);
static void Att_RemoveAllTheGrpsAssociatedToAnAttEvent (long AttCod); static void Att_RemoveAllTheGrpsAssociatedToAnAttEvent (long AttCod);
@ -474,8 +474,8 @@ static void Att_WriteAttEventAuthor (struct AttendanceEvent *Att)
{ {
bool ShowPhoto = false; bool ShowPhoto = false;
char PhotoURL[PATH_MAX+1]; char PhotoURL[PATH_MAX+1];
char FirstName[Usr_MAX_BYTES_NAME+1]; char FirstName[Usr_MAX_BYTES_NAME + 1];
char Surnames[2*(Usr_MAX_BYTES_NAME+1)]; char Surnames[Usr_MAX_BYTES_SURNAMES + 1];
struct UsrData UsrDat; struct UsrData UsrDat;
/***** Initialize structure with user's data *****/ /***** Initialize structure with user's data *****/
@ -492,8 +492,12 @@ static void Att_WriteAttEventAuthor (struct AttendanceEvent *Att)
"PHOTO15x20",Pho_ZOOM,false); "PHOTO15x20",Pho_ZOOM,false);
/***** Write name *****/ /***** Write name *****/
strcpy (FirstName,UsrDat.FirstName); strncpy (FirstName,UsrDat.FirstName,Usr_MAX_BYTES_NAME);
strcpy (Surnames,UsrDat.Surname1); FirstName[Usr_MAX_BYTES_NAME] = '\0';
strncpy (Surnames,UsrDat.Surname1,Usr_MAX_BYTES_SURNAMES);
Surnames[Usr_MAX_BYTES_SURNAMES] = '\0';
if (UsrDat.Surname2[0]) if (UsrDat.Surname2[0])
{ {
strcat (Surnames," "); strcat (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]) */
strcpy (Att->Title,row[8]); strncpy (Att->Title,row[8],Att_MAX_LENGTH_ATTENDANCE_EVENT_TITLE);
Att->Title[Att_MAX_LENGTH_ATTENDANCE_EVENT_TITLE] = '\0';
} }
/***** Free structure that stores the query result *****/ /***** Free structure that stores the query result *****/
@ -836,7 +841,7 @@ void Att_FreeListAttEvents (void)
/***************** Get attendance event text from database *******************/ /***************** Get attendance event text from database *******************/
/*****************************************************************************/ /*****************************************************************************/
static void Att_GetAttEventTxtFromDB (long AttCod,char *Txt) static void Att_GetAttEventTxtFromDB (long AttCod,char Txt[Cns_MAX_BYTES_TEXT + 1])
{ {
char Query[256]; char Query[256];
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
@ -852,9 +857,12 @@ static void Att_GetAttEventTxtFromDB (long AttCod,char *Txt)
/***** The result of the query must have one row or none *****/ /***** The result of the query must have one row or none *****/
if (NumRows == 1) if (NumRows == 1)
{ {
/* Get info text */ /* Get row */
row = mysql_fetch_row (mysql_res); row = mysql_fetch_row (mysql_res);
strcpy (Txt,row[0]);
/* Get info text */
strncpy (Txt,row[0],Cns_MAX_BYTES_TEXT);
Txt[Cns_MAX_BYTES_TEXT] = '\0';
} }
else else
Txt[0] = '\0'; Txt[0] = '\0';
@ -866,48 +874,6 @@ static void Att_GetAttEventTxtFromDB (long AttCod,char *Txt)
Lay_ShowErrorAndExit ("Error when getting attendance event text."); Lay_ShowErrorAndExit ("Error when getting attendance event text.");
} }
/*****************************************************************************/
/************** Get summary and content of an attendance event ***************/
/*****************************************************************************/
// This function may be called inside a web service, so don't report error
void Att_GetNotifAttEvent (char *SummaryStr,char **ContentStr,long AttCod,unsigned MaxChars,bool GetContent)
{
char Query[512];
MYSQL_RES *mysql_res;
MYSQL_ROW row;
SummaryStr[0] = '\0'; // Return nothing on error
/***** Build query *****/
sprintf (Query,"SELECT Title,Txt FROM att_events WHERE AttCod='%ld'",
AttCod);
if (!mysql_query (&Gbl.mysql,Query))
if ((mysql_res = mysql_store_result (&Gbl.mysql)) != NULL)
{
/***** Result should have a unique row *****/
if (mysql_num_rows (mysql_res) == 1)
{
/***** Get row *****/
row = mysql_fetch_row (mysql_res);
/***** Get summary *****/
strcpy (SummaryStr,row[0]);
if (MaxChars)
Str_LimitLengthHTMLStr (SummaryStr,MaxChars);
/***** Get content *****/
if (GetContent)
{
if ((*ContentStr = (char *) malloc (512+Cns_MAX_BYTES_TEXT)) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for notification content.");
strcpy (*ContentStr,row[1]);
}
}
mysql_free_result (mysql_res);
}
}
/*****************************************************************************/ /*****************************************************************************/
/************** Write parameter with code of attendance event ****************/ /************** Write parameter with code of attendance event ****************/
/*****************************************************************************/ /*****************************************************************************/
@ -1113,7 +1079,7 @@ void Att_RequestCreatOrEditAttEvent (void)
extern const char *Txt_Save; extern const char *Txt_Save;
struct AttendanceEvent Att; struct AttendanceEvent Att;
bool ItsANewAttEvent; bool ItsANewAttEvent;
char Txt[Cns_MAX_BYTES_TEXT+1]; char Txt[Cns_MAX_BYTES_TEXT + 1];
/***** Get parameters *****/ /***** Get parameters *****/
Att_GetParamAttOrderType (); Att_GetParamAttOrderType ();

View File

@ -8,7 +8,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as
@ -34,7 +34,7 @@
/************************** Public types and constants ***********************/ /************************** Public types and constants ***********************/
/*****************************************************************************/ /*****************************************************************************/
#define Att_MAX_LENGTH_ATTENDANCE_EVENT_TITLE 255 #define Att_MAX_LENGTH_ATTENDANCE_EVENT_TITLE (256-1)
#define Att_NUM_DATES 2 #define Att_NUM_DATES 2
typedef enum typedef enum
@ -51,7 +51,7 @@ struct AttendanceEvent
long UsrCod; long UsrCod;
time_t TimeUTC[Att_NUM_DATES]; time_t TimeUTC[Att_NUM_DATES];
bool Open; bool Open;
char Title[Att_MAX_LENGTH_ATTENDANCE_EVENT_TITLE+1]; char Title[Att_MAX_LENGTH_ATTENDANCE_EVENT_TITLE + 1];
bool CommentTchVisible; bool CommentTchVisible;
unsigned NumStdsTotal; // Number total of students who have assisted to the event unsigned NumStdsTotal; // Number total of students who have assisted to the event
unsigned NumStdsFromList; // Number of students (taken from a list) who has assisted to the event unsigned NumStdsFromList; // Number of students (taken from a list) who has assisted to the event
@ -76,8 +76,6 @@ void Att_RequestCreatOrEditAttEvent (void);
bool Att_GetDataOfAttEventByCod (struct AttendanceEvent *Att); bool Att_GetDataOfAttEventByCod (struct AttendanceEvent *Att);
void Att_FreeListAttEvents (void); void Att_FreeListAttEvents (void);
void Att_GetNotifAttEvent (char *SummaryStr,char **ContentStr,long AsgCod,unsigned MaxChars,bool GetContent);
void Att_PutParamAttCod (long AttCod); void Att_PutParamAttCod (long AttCod);
long Att_GetParamAttCod (void); long Att_GetParamAttCod (void);

View File

@ -6,7 +6,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cańas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as
@ -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]) */
strcpy (Ban->ShrtName,row[2]); strncpy (Ban->ShrtName,row[2],Ban_MAX_LENGTH_SHRT_NAME);
Ban->ShrtName[Ban_MAX_LENGTH_SHRT_NAME] = '\0';
/* Get the full name of the banner (row[3]) */ /* Get the full name of the banner (row[3]) */
strcpy (Ban->FullName,row[3]); strncpy (Ban->FullName,row[3],Ban_MAX_LENGTH_FULL_NAME);
Ban->FullName[Ban_MAX_LENGTH_FULL_NAME] = '\0';
/* Get the image of the banner (row[4]) */ /* Get the image of the banner (row[4]) */
strcpy (Ban->Img,row[4]); strncpy (Ban->Img,row[4],Ban_MAX_LENGTH_IMAGE);
Ban->Img[Ban_MAX_LENGTH_IMAGE] = '\0';
/* Get the URL of the banner (row[5]) */ /* Get the URL of the banner (row[5]) */
strcpy (Ban->WWW,row[5]); strncpy (Ban->WWW,row[5],Cns_MAX_LENGTH_WWW);
Ban->WWW[Cns_MAX_LENGTH_WWW] = '\0';
} }
} }
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]) */
strcpy (Ban->ShrtName,row[1]); strncpy (Ban->ShrtName,row[1],Ban_MAX_LENGTH_SHRT_NAME);
Ban->ShrtName[Ban_MAX_LENGTH_SHRT_NAME] = '\0';
/* Get the full name of the banner (row[2]) */ /* Get the full name of the banner (row[2]) */
strcpy (Ban->FullName,row[2]); strncpy (Ban->FullName,row[2],Ban_MAX_LENGTH_FULL_NAME);
Ban->FullName[Ban_MAX_LENGTH_FULL_NAME] = '\0';
/* Get the image of the banner (row[3]) */ /* Get the image of the banner (row[3]) */
strcpy (Ban->Img,row[3]); strncpy (Ban->Img,row[3],Ban_MAX_LENGTH_IMAGE);
Ban->Img[Ban_MAX_LENGTH_IMAGE] = '\0';
/* Get the URL of the banner (row[4]) */ /* Get the URL of the banner (row[4]) */
strcpy (Ban->WWW,row[4]); strncpy (Ban->WWW,row[4],Cns_MAX_LENGTH_WWW);
Ban->WWW[Cns_MAX_LENGTH_WWW] = '\0';
} }
/***** Free structure that stores the query result *****/ /***** Free structure that stores the query result *****/
@ -616,7 +624,9 @@ static void Ban_RenameBanner (Cns_ShrtOrFullName_t ShrtOrFullName)
} }
/***** Show the form again *****/ /***** Show the form again *****/
strcpy (CurrentBanName,NewBanName); strncpy (CurrentBanName,NewBanName,MaxLength);
CurrentBanName[MaxLength] = '\0';
Ban_EditBanners (); Ban_EditBanners ();
} }
@ -673,7 +683,9 @@ 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 *****/
strcpy (Ban->Img,NewImg); strncpy (Ban->Img,NewImg,Ban_MAX_LENGTH_IMAGE);
Ban->Img[Ban_MAX_LENGTH_IMAGE] = '\0';
Ban_EditBanners (); Ban_EditBanners ();
} }
@ -687,7 +699,7 @@ void Ban_ChangeBannerWWW (void)
extern const char *Txt_You_can_not_leave_the_web_address_empty; extern const char *Txt_You_can_not_leave_the_web_address_empty;
struct Banner *Ban; struct Banner *Ban;
char Query[256+Cns_MAX_LENGTH_WWW]; char Query[256+Cns_MAX_LENGTH_WWW];
char NewWWW[Cns_MAX_LENGTH_WWW+1]; char NewWWW[Cns_MAX_LENGTH_WWW + 1];
Ban = &Gbl.Banners.EditingBan; Ban = &Gbl.Banners.EditingBan;
@ -716,7 +728,9 @@ 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 *****/
strcpy (Ban->WWW,NewWWW); strncpy (Ban->WWW,NewWWW,Cns_MAX_LENGTH_WWW);
Ban->WWW[Cns_MAX_LENGTH_WWW] = '\0';
Ban_EditBanners (); Ban_EditBanners ();
} }

View File

@ -8,7 +8,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as
@ -41,10 +41,10 @@ struct Banner
{ {
long BanCod; long BanCod;
bool Hidden; bool Hidden;
char ShrtName[Ban_MAX_LENGTH_SHRT_NAME+1]; char ShrtName[Ban_MAX_LENGTH_SHRT_NAME + 1];
char FullName[Ban_MAX_LENGTH_FULL_NAME+1]; char FullName[Ban_MAX_LENGTH_FULL_NAME + 1];
char Img[Ban_MAX_LENGTH_IMAGE+1]; char Img[Ban_MAX_LENGTH_IMAGE + 1];
char WWW[Cns_MAX_LENGTH_WWW+1]; char WWW[Cns_MAX_LENGTH_WWW + 1];
}; };
/*****************************************************************************/ /*****************************************************************************/

View File

@ -6,7 +6,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as

View File

@ -8,7 +8,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as

View File

@ -6,7 +6,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as
@ -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]) */
strcpy (Ctr->ShrtName,row[5]); strncpy (Ctr->ShrtName,row[5],Ctr_MAX_LENGTH_CENTRE_SHRT_NAME);
Ctr->ShrtName[Ctr_MAX_LENGTH_CENTRE_SHRT_NAME] = '\0';
/* Get the full name of the centre (row[6]) */ /* Get the full name of the centre (row[6]) */
strcpy (Ctr->FullName,row[6]); strncpy (Ctr->FullName,row[6],Ctr_MAX_LENGTH_CENTRE_FULL_NAME);
Ctr->FullName[Ctr_MAX_LENGTH_CENTRE_FULL_NAME] = '\0';
/* Get the URL of the centre (row[7]) */ /* Get the URL of the centre (row[7]) */
strcpy (Ctr->WWW,row[7]); strncpy (Ctr->WWW,row[7],Cns_MAX_LENGTH_WWW);
Ctr->WWW[Cns_MAX_LENGTH_WWW] = '\0';
/* 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]) */
strcpy (Ctr->ShrtName,row[4]); strncpy (Ctr->ShrtName,row[4],Ctr_MAX_LENGTH_CENTRE_SHRT_NAME);
Ctr->ShrtName[Ctr_MAX_LENGTH_CENTRE_SHRT_NAME] = '\0';
/* Get the full name of the centre (row[5]) */ /* Get the full name of the centre (row[5]) */
strcpy (Ctr->FullName,row[5]); strncpy (Ctr->FullName,row[5],Ctr_MAX_LENGTH_CENTRE_FULL_NAME);
Ctr->FullName[Ctr_MAX_LENGTH_CENTRE_FULL_NAME] = '\0';
/* Get the URL of the centre (row[6]) */ /* Get the URL of the centre (row[6]) */
strcpy (Ctr->WWW,row[6]); strncpy (Ctr->WWW,row[6],Cns_MAX_LENGTH_WWW);
Ctr->WWW[Cns_MAX_LENGTH_WWW] = '\0';
/* 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)
@ -1216,7 +1222,9 @@ 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);
strcpy (Ctr->ShrtName,row[0]);
strncpy (Ctr->ShrtName,row[0],Ctr_MAX_LENGTH_CENTRE_SHRT_NAME);
Ctr->ShrtName[Ctr_MAX_LENGTH_CENTRE_SHRT_NAME] = '\0';
} }
/***** Free structure that stores the query result *****/ /***** Free structure that stores the query result *****/
@ -1233,6 +1241,7 @@ static void Ctr_GetPhotoAttribution (long CtrCod,char **PhotoAttribution)
char Query[128]; char Query[128];
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
MYSQL_ROW row; MYSQL_ROW row;
size_t Length;
/***** Free possible former photo attribution *****/ /***** Free possible former photo attribution *****/
Ctr_FreePhotoAttribution (PhotoAttribution); Ctr_FreePhotoAttribution (PhotoAttribution);
@ -1249,9 +1258,13 @@ static void Ctr_GetPhotoAttribution (long CtrCod,char **PhotoAttribution)
if (row[0]) if (row[0])
if (row[0][0]) if (row[0][0])
{ {
if (((*PhotoAttribution) = (char *) malloc (strlen (row[0])+1)) == NULL) Length = strlen (row[0]);
if (((*PhotoAttribution) = (char *) malloc (Length + 1)) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for photo attribution."); Lay_ShowErrorAndExit ("Error allocating memory for photo attribution.");
strcpy (*PhotoAttribution,row[0]);
strncpy (*PhotoAttribution,row[0],Length);
PhotoAttribution[Length] = '\0';
} }
} }
@ -1999,7 +2012,9 @@ 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);
strcpy (Ctr->WWW,NewWWW);
strncpy (Ctr->WWW,NewWWW,Cns_MAX_LENGTH_WWW);
Ctr->WWW[Cns_MAX_LENGTH_WWW] = '\0';
/***** 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);
@ -2030,7 +2045,9 @@ 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);
strcpy (Gbl.CurrentCtr.Ctr.WWW,NewWWW);
strncpy (Gbl.CurrentCtr.Ctr.WWW,NewWWW,Cns_MAX_LENGTH_WWW);
Gbl.CurrentCtr.Ctr.WWW[Cns_MAX_LENGTH_WWW] = '\0';
/***** 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

@ -8,7 +8,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cańas Vargas Copyright (C) 1999-2017 Antonio Cańas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as
@ -65,9 +65,9 @@ struct Centre
long PlcCod; // Place code long PlcCod; // Place code
Ctr_Status_t Status; // Centre status Ctr_Status_t Status; // Centre status
long RequesterUsrCod; // User code of the person who requested the creation of this centre long RequesterUsrCod; // User code of the person who requested the creation of this centre
char ShrtName[Ctr_MAX_LENGTH_CENTRE_SHRT_NAME+1]; char ShrtName[Ctr_MAX_LENGTH_CENTRE_SHRT_NAME + 1];
char FullName[Ctr_MAX_LENGTH_CENTRE_FULL_NAME+1]; char FullName[Ctr_MAX_LENGTH_CENTRE_FULL_NAME + 1];
char WWW[Cns_MAX_LENGTH_WWW+1]; char WWW[Cns_MAX_LENGTH_WWW + 1];
unsigned NumUsrsWhoClaimToBelongToCtr; // Number of users who claim to belong in this centre unsigned NumUsrsWhoClaimToBelongToCtr; // Number of users who claim to belong in this centre
struct ListDegrees Degs; // List of degrees in this centre struct ListDegrees Degs; // List of degrees in this centre
unsigned NumCrss; // Number of courses in this centre unsigned NumCrss; // Number of courses in this centre

View File

@ -8,7 +8,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as
@ -189,13 +189,14 @@
/****************************** Public constants *****************************/ /****************************** Public constants *****************************/
/*****************************************************************************/ /*****************************************************************************/
#define Log_PLATFORM_VERSION "SWAD 16.111.16 (2016-12-30)" #define Log_PLATFORM_VERSION "SWAD 16.112 (2017-01-13)"
#define CSS_FILE "swad16.111.5.css" #define CSS_FILE "swad16.111.5.css"
#define JS_FILE "swad16.101.js" #define JS_FILE "swad16.101.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.112: Jan 13, 2017 Some strcpy changed to strncpy. (211415 lines)
Version 16.111.16:Dec 30, 2016 Fixed minor bug in user's ID, reported by Coverity. (211185 lines) Version 16.111.16:Dec 30, 2016 Fixed minor bug in user's ID, reported by Coverity. (211185 lines)
Version 16.111.15:Dec 30, 2016 Fixed bug in forums, reported by Coverity. (211182 lines) Version 16.111.15:Dec 30, 2016 Fixed bug in forums, reported by Coverity. (211182 lines)
Version 16.111.14:Dec 29, 2016 Fixed bug in attendance events. (211189 lines) Version 16.111.14:Dec 29, 2016 Fixed bug in attendance events. (211189 lines)

View File

@ -6,7 +6,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as
@ -29,6 +29,7 @@
#include <stdbool.h> // For boolean type #include <stdbool.h> // For boolean type
#include <stdio.h> // For sprintf #include <stdio.h> // For sprintf
#include <string.h> #include <string.h>
#include <sys/param.h> // For MAX()
#include "swad_chat.h" #include "swad_chat.h"
#include "swad_config.h" #include "swad_config.h"
@ -382,20 +383,20 @@ void Cht_OpenChatWindow (void)
extern const char *Txt_Teachers_ABBREVIATION; extern const char *Txt_Teachers_ABBREVIATION;
extern const char *Txt_Degree; extern const char *Txt_Degree;
extern const char *Txt_Course; extern const char *Txt_Course;
char RoomCode [MAX_LENGTH_ROOM_CODE +1]; char RoomCode [MAX_LENGTH_ROOM_CODE + 1];
char RoomShortName[MAX_LENGTH_ROOM_SHRT_NAME+1]; char RoomShortName[MAX_LENGTH_ROOM_SHRT_NAME + 1];
char RoomFullName [MAX_LENGTH_ROOM_FULL_NAME +1]; char RoomFullName [MAX_LENGTH_ROOM_FULL_NAME + 1];
char UsrName[3*(Usr_MAX_BYTES_NAME+1)]; char UsrName[Usr_MAX_BYTES_FULL_NAME + 1];
unsigned NumMyDeg; unsigned NumMyDeg;
unsigned NumMyCrs; unsigned NumMyCrs;
struct Degree Deg; struct Degree Deg;
struct Course Crs; struct Course Crs;
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 [(3+Deg_MAX_DEGREES_PER_USR+Crs_MAX_COURSES_PER_USR)*MAX_LENGTH_ROOM_CODE +1]; char ListRoomCodes [(2 + Deg_MAX_DEGREES_PER_USR + Crs_MAX_COURSES_PER_USR) * MAX_LENGTH_ROOM_CODE + 1];
char ListRoomShortNames[(3+Deg_MAX_DEGREES_PER_USR+Crs_MAX_COURSES_PER_USR)*MAX_LENGTH_ROOM_SHRT_NAME+1]; char ListRoomShortNames[(2 + Deg_MAX_DEGREES_PER_USR + Crs_MAX_COURSES_PER_USR) * MAX_LENGTH_ROOM_SHRT_NAME + 1];
char ListRoomFullNames [(3+Deg_MAX_DEGREES_PER_USR+Crs_MAX_COURSES_PER_USR)*MAX_LENGTH_ROOM_FULL_NAME +1]; char ListRoomFullNames [(2 + Deg_MAX_DEGREES_PER_USR + Crs_MAX_COURSES_PER_USR) * MAX_LENGTH_ROOM_FULL_NAME + 1];
FILE *FileChat; FILE *FileChat;
/***** Get the code and the nombre of the room *****/ /***** Get the code and the nombre of the room *****/
@ -415,45 +416,99 @@ void Cht_OpenChatWindow (void)
Usr_GetMyCourses (); Usr_GetMyCourses ();
/***** Build my user's name *****/ /***** Build my user's name *****/
strcpy (UsrName,Gbl.Usrs.Me.UsrDat.Surname1); strncpy (UsrName,Gbl.Usrs.Me.UsrDat.Surname1,Usr_MAX_BYTES_NAME);
UsrName[Usr_MAX_BYTES_NAME] = '\0';
if (Gbl.Usrs.Me.UsrDat.Surname2[0]) if (Gbl.Usrs.Me.UsrDat.Surname2[0])
{ {
strcat (UsrName," "); strncat (UsrName," ",1);
strcat (UsrName,Gbl.Usrs.Me.UsrDat.Surname2); strncat (UsrName,Gbl.Usrs.Me.UsrDat.Surname2,Usr_MAX_BYTES_NAME);
} }
strcat (UsrName,", "); strncat (UsrName,", ",2);
strcat (UsrName,Gbl.Usrs.Me.UsrDat.FirstName); strncat (UsrName,Gbl.Usrs.Me.UsrDat.FirstName,Usr_MAX_BYTES_NAME);
/***** Build the lists of available rooms *****/ /***** Build the lists of available rooms *****/
sprintf (ListRoomCodes,"#%s",RoomCode); sprintf (ListRoomCodes,"#%s",RoomCode);
strcpy (ListRoomShortNames,RoomShortName);
strcpy (ListRoomFullNames ,RoomFullName); strncpy (ListRoomShortNames,RoomShortName,sizeof (ListRoomShortNames) - 1);
ListRoomShortNames[sizeof (ListRoomShortNames) - 1] = '\0';
strncpy (ListRoomFullNames ,RoomFullName,sizeof (ListRoomFullNames) - 1);
ListRoomFullNames[sizeof (ListRoomFullNames) - 1] = '\0';
if (strcmp (RoomCode,"GBL_USR")) if (strcmp (RoomCode,"GBL_USR"))
{ {
strcat (ListRoomCodes,"|#GBL_USR"); strncat (ListRoomCodes,"|#GBL_USR",
MAX (0,
sizeof (ListRoomCodes) - 1 -
strlen (ListRoomCodes) -
strlen ("|#GBL_USR")));
sprintf (RoomShortName,"|%s",Txt_SEX_PLURAL_Abc[Usr_SEX_ALL]); sprintf (RoomShortName,"|%s",Txt_SEX_PLURAL_Abc[Usr_SEX_ALL]);
strcat (ListRoomShortNames,RoomShortName); strncat (ListRoomShortNames,RoomShortName,
sprintf (RoomFullName,"|%s (%s)",Txt_General,Txt_SEX_PLURAL_abc[Usr_SEX_ALL]); MAX (0,
strcat (ListRoomFullNames,RoomFullName); sizeof (ListRoomShortNames) - 1 -
strlen (ListRoomShortNames) -
strlen (RoomShortName)));
sprintf (RoomFullName,"|%s (%s)",
Txt_General,Txt_SEX_PLURAL_abc[Usr_SEX_ALL]);
strncat (ListRoomFullNames,RoomFullName,
MAX (0,
sizeof (ListRoomFullNames) - 1 -
strlen (ListRoomFullNames) -
strlen (RoomFullName)));
} }
if (Gbl.Usrs.Me.LoggedRole == Rol_STUDENT) if (Gbl.Usrs.Me.LoggedRole == Rol_STUDENT)
if (strcmp (RoomCode,"GBL_STD")) if (strcmp (RoomCode,"GBL_STD"))
{ {
strcat (ListRoomCodes,"|#GBL_STD"); strncat (ListRoomCodes,"|#GBL_STD",
MAX (0,
sizeof (ListRoomCodes) - 1 -
strlen (ListRoomCodes) -
strlen ("|#GBL_STD")));
sprintf (RoomShortName,"|%s",Txt_Students_ABBREVIATION); sprintf (RoomShortName,"|%s",Txt_Students_ABBREVIATION);
strcat (ListRoomShortNames,RoomShortName); strncat (ListRoomShortNames,RoomShortName,
sprintf (RoomFullName,"|%s (%s)",Txt_General,Txt_ROLES_PLURAL_abc[Rol_STUDENT][Usr_SEX_ALL]); MAX (0,
strcat (ListRoomFullNames,RoomFullName); sizeof (ListRoomShortNames) - 1 -
strlen (ListRoomShortNames) -
strlen (RoomShortName)));
sprintf (RoomFullName,"|%s (%s)",Txt_General,
Txt_ROLES_PLURAL_abc[Rol_STUDENT][Usr_SEX_ALL]);
strncat (ListRoomFullNames,RoomFullName,
MAX (0,
sizeof (ListRoomFullNames) - 1 -
strlen (ListRoomFullNames) -
strlen (RoomFullName)));
} }
if (Gbl.Usrs.Me.LoggedRole == Rol_TEACHER) if (Gbl.Usrs.Me.LoggedRole == Rol_TEACHER)
if (strcmp (RoomCode,"GBL_TCH")) if (strcmp (RoomCode,"GBL_TCH"))
{ {
strcat (ListRoomCodes,"|#GBL_TCH"); strncat (ListRoomCodes,"|#GBL_TCH",
MAX (0,
sizeof (ListRoomCodes) - 1 -
strlen (ListRoomCodes) -
strlen ("|#GBL_TCH")));
sprintf (RoomShortName,"|%s",Txt_Teachers_ABBREVIATION); sprintf (RoomShortName,"|%s",Txt_Teachers_ABBREVIATION);
strcat (ListRoomShortNames,RoomShortName); strncat (ListRoomShortNames,RoomShortName,
sprintf (RoomFullName,"|%s (%s)",Txt_General,Txt_ROLES_PLURAL_abc[Rol_TEACHER][Usr_SEX_ALL]); MAX (0,
strcat (ListRoomFullNames,RoomFullName); sizeof (ListRoomShortNames) - 1 -
strlen (ListRoomShortNames) -
strlen (RoomShortName)));
sprintf (RoomFullName,"|%s (%s)",
Txt_General,Txt_ROLES_PLURAL_abc[Rol_TEACHER][Usr_SEX_ALL]);
strncat (ListRoomFullNames,RoomFullName,
MAX (0,
sizeof (ListRoomFullNames) - 1 -
strlen (ListRoomFullNames) -
strlen (RoomFullName)));
} }
for (NumMyDeg = 0; for (NumMyDeg = 0;
NumMyDeg < Gbl.Usrs.Me.MyDegs.Num; NumMyDeg < Gbl.Usrs.Me.MyDegs.Num;
NumMyDeg++) NumMyDeg++)
@ -461,22 +516,52 @@ void Cht_OpenChatWindow (void)
sprintf (ThisRoomCode,"DEG_%ld",Gbl.Usrs.Me.MyDegs.Degs[NumMyDeg].DegCod); sprintf (ThisRoomCode,"DEG_%ld",Gbl.Usrs.Me.MyDegs.Degs[NumMyDeg].DegCod);
if (strcmp (RoomCode,ThisRoomCode)) if (strcmp (RoomCode,ThisRoomCode))
{ {
strcat (ListRoomCodes,"|#"); strncat (ListRoomCodes,"|#",
strcat (ListRoomCodes,ThisRoomCode); MAX (0,
sizeof (ListRoomCodes) - 1 -
strlen (ListRoomCodes) -
strlen ("|#")));
strncat (ListRoomCodes,ThisRoomCode,
MAX (0,
sizeof (ListRoomCodes) - 1 -
strlen (ListRoomCodes) -
strlen (ThisRoomCode)));
/* Get data of this degree */ /* Get data of this degree */
Deg.DegCod = Gbl.Usrs.Me.MyDegs.Degs[NumMyDeg].DegCod; Deg.DegCod = Gbl.Usrs.Me.MyDegs.Degs[NumMyDeg].DegCod;
Deg_GetDataOfDegreeByCod (&Deg); Deg_GetDataOfDegreeByCod (&Deg);
sprintf (ThisRoomShortName,"%s",Deg.ShrtName); sprintf (ThisRoomShortName,"%s",Deg.ShrtName);
strcat (ListRoomShortNames,"|");
strcat (ListRoomShortNames,ThisRoomShortName); strncat (ListRoomShortNames,"|",
MAX (0,
sizeof (ListRoomShortNames) - 1 -
strlen (ListRoomShortNames) -
strlen ("|")));
strncat (ListRoomShortNames,ThisRoomShortName,
MAX (0,
sizeof (ListRoomShortNames) - 1 -
strlen (ListRoomShortNames) -
strlen (ThisRoomShortName)));
sprintf (ThisRoomFullName,"%s %s",Txt_Degree,Deg.ShrtName); sprintf (ThisRoomFullName,"%s %s",Txt_Degree,Deg.ShrtName);
strcat (ListRoomFullNames,"|");
strcat (ListRoomFullNames,ThisRoomFullName); strncat (ListRoomFullNames,"|",
MAX (0,
sizeof (ListRoomFullNames) - 1 -
strlen (ListRoomFullNames) -
strlen ("|")));
strncat (ListRoomFullNames,ThisRoomFullName,
MAX (0,
sizeof (ListRoomFullNames) - 1 -
strlen (ListRoomFullNames) -
strlen (ThisRoomFullName)));
} }
} }
for (NumMyCrs = 0; for (NumMyCrs = 0;
NumMyCrs < Gbl.Usrs.Me.MyCrss.Num; NumMyCrs < Gbl.Usrs.Me.MyCrss.Num;
NumMyCrs++) NumMyCrs++)
@ -484,20 +569,53 @@ void Cht_OpenChatWindow (void)
sprintf (ThisRoomCode,"CRS_%ld",Gbl.Usrs.Me.MyCrss.Crss[NumMyCrs].CrsCod); sprintf (ThisRoomCode,"CRS_%ld",Gbl.Usrs.Me.MyCrss.Crss[NumMyCrs].CrsCod);
if (strcmp (RoomCode,ThisRoomCode)) if (strcmp (RoomCode,ThisRoomCode))
{ {
strcat (ListRoomCodes,"|#"); strncat (ListRoomCodes,"|#",
strcat (ListRoomCodes,ThisRoomCode); MAX (0,
sizeof (ListRoomCodes) - 1 -
strlen (ListRoomCodes) -
strlen ("|#")));
strncat (ListRoomCodes,ThisRoomCode,
MAX (0,
sizeof (ListRoomCodes) - 1 -
strlen (ListRoomCodes) -
strlen (ThisRoomCode)));
/* Get data of this course */ /* Get data of this course */
Crs.CrsCod = Gbl.Usrs.Me.MyCrss.Crss[NumMyCrs].CrsCod; Crs.CrsCod = Gbl.Usrs.Me.MyCrss.Crss[NumMyCrs].CrsCod;
Crs_GetDataOfCourseByCod (&Crs); Crs_GetDataOfCourseByCod (&Crs);
sprintf (ThisRoomShortName,"%s",Crs.ShrtName); sprintf (ThisRoomShortName,"%s",Crs.ShrtName);
strcat (ListRoomShortNames,"|"); strncat (ListRoomShortNames,"|",
strcat (ListRoomShortNames,ThisRoomShortName); MAX (0,
sizeof (ListRoomShortNames) - 1 -
strlen (ListRoomShortNames) -
strlen ("|")));
strncat (ListRoomShortNames,ThisRoomShortName,
MAX (0,
sizeof (ListRoomShortNames) - 1 -
strlen (ListRoomShortNames) -
strlen (ThisRoomShortName)));
strncat (ListRoomShortNames,"|",
MAX (0,
sizeof (ListRoomShortNames) - 1 -
strlen (ListRoomShortNames) -
strlen (ThisRoomShortName)));
sprintf (ThisRoomFullName,"%s %s",Txt_Course,Crs.ShrtName); sprintf (ThisRoomFullName,"%s %s",Txt_Course,Crs.ShrtName);
strcat (ListRoomFullNames,"|"); strncat (ListRoomFullNames,"|",
strcat (ListRoomFullNames,ThisRoomFullName); MAX (0,
sizeof (ListRoomFullNames) - 1 -
strlen (ListRoomFullNames) -
strlen ("|")));
strncat (ListRoomFullNames,"|",
MAX (0,
sizeof (ListRoomFullNames) - 1 -
strlen (ListRoomFullNames) -
strlen (ThisRoomFullName)));
} }
} }

View File

@ -8,7 +8,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as

View File

@ -6,7 +6,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General 3 License as it under the terms of the GNU Affero General 3 License as

View File

@ -8,7 +8,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as

View File

@ -6,7 +6,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as
@ -457,39 +457,56 @@ 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[Deg_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 *****/
switch (Gbl.Scope.Current) switch (Gbl.Scope.Current)
{ {
case Sco_SCOPE_SYS: // Show connected users in the whole platform case Sco_SCOPE_SYS: // Show connected users in the whole platform
strcpy (LocationName,Cfg_PLATFORM_SHORT_NAME); strncpy (LocationName,Cfg_PLATFORM_SHORT_NAME,
Deg_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR);
LocationName[Deg_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR] = '\0';
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;
strcpy (LocationName,Gbl.CurrentCty.Cty.Name[Gbl.Prefs.Language]);
strncpy (LocationName,Gbl.CurrentCty.Cty.Name[Gbl.Prefs.Language],
Deg_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR);
LocationName[Deg_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR] = '\0';
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;
strcpy (LocationName,Gbl.CurrentIns.Ins.ShrtName);
strncpy (LocationName,Gbl.CurrentIns.Ins.ShrtName,
Deg_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR);
LocationName[Deg_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR] = '\0';
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;
strcpy (LocationName,Gbl.CurrentCtr.Ctr.ShrtName);
strncpy (LocationName,Gbl.CurrentCtr.Ctr.ShrtName,
Deg_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR);
LocationName[Deg_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR] = '\0';
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;
strcpy (LocationName,Gbl.CurrentDeg.Deg.ShrtName);
strncpy (LocationName,Gbl.CurrentDeg.Deg.ShrtName,
Deg_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR);
LocationName[Deg_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR] = '\0';
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;
strcpy (LocationName,Gbl.CurrentCrs.Crs.ShrtName);
strncpy (LocationName,Gbl.CurrentCrs.Crs.ShrtName,
Deg_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR);
LocationName[Deg_MAX_LENGTH_LOCATION_SHORT_NAME_SPEC_CHAR] = '\0';
break; break;
default: default:
return; return;
@ -541,7 +558,7 @@ void Con_ShowConnectedUsrsBelongingToCurrentCrs (void)
extern const char *The_ClassConnected[The_NUM_THEMES]; extern const char *The_ClassConnected[The_NUM_THEMES];
extern const char *Txt_Connected_users; extern const char *Txt_Connected_users;
extern const char *Txt_from; extern const char *Txt_from;
char CourseName[Crs_MAX_LENGTH_COURSE_SHRT_NAME+1]; char CourseName[Crs_MAX_LENGTH_COURSE_SHRT_NAME + 1];
struct ConnectedUsrs Usrs; struct ConnectedUsrs Usrs;
if (Gbl.CurrentCrs.Crs.CrsCod <= 0) // There is no course selected if (Gbl.CurrentCrs.Crs.CrsCod <= 0) // There is no course selected
@ -558,7 +575,9 @@ void Con_ShowConnectedUsrsBelongingToCurrentCrs (void)
Act_LinkFormSubmitUnique (Txt_Connected_users,The_ClassConnected[Gbl.Prefs.Theme]); Act_LinkFormSubmitUnique (Txt_Connected_users,The_ClassConnected[Gbl.Prefs.Theme]);
/* Write total number of connected users belonging to the current course */ /* Write total number of connected users belonging to the current course */
strcpy (CourseName,Gbl.CurrentCrs.Crs.ShrtName); strncpy (CourseName,Gbl.CurrentCrs.Crs.ShrtName,
Crs_MAX_LENGTH_COURSE_SHRT_NAME);
CourseName[Crs_MAX_LENGTH_COURSE_SHRT_NAME] = '\0';
Str_LimitLengthHTMLStr (CourseName,12); Str_LimitLengthHTMLStr (CourseName,12);
Con_GetNumConnectedUsrsWithARoleBelongingCurrentLocation (Rol_UNKNOWN,&Usrs); Con_GetNumConnectedUsrsWithARoleBelongingCurrentLocation (Rol_UNKNOWN,&Usrs);
fprintf (Gbl.F.Out,"%u %s %s", fprintf (Gbl.F.Out,"%u %s %s",

View File

@ -8,7 +8,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as

View File

@ -8,7 +8,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as
@ -33,24 +33,24 @@
/***************************** Public constants ******************************/ /***************************** Public constants ******************************/
/*****************************************************************************/ /*****************************************************************************/
#define Cns_MAX_LENGTH_WWW 255 // Max. length of a URL #define Cns_MAX_LENGTH_WWW (256 - 1) // Max. length of a URL
#define Cns_MAX_LENGTH_IP 15 // Max. bytes of an IP address #define Cns_MAX_LENGTH_IP (16 - 1) // Max. bytes of an IP address
#define Cns_MAX_LENGTH_DATE (4+1+2+1+2) #define Cns_MAX_LENGTH_DATE (4+1+2+1+2)
#define Cns_MAX_BYTES_DATE 19 // Examples: "20030614143857", "14/06/2003 14:38:57" #define Cns_MAX_BYTES_DATE 19 // Examples: "20030614143857", "14/06/2003 14:38:57"
#define Cns_MAX_LENGTH_SUBJECT 255 #define Cns_MAX_LENGTH_SUBJECT (256 - 1)
#define Cns_MAX_BYTES_SUBJECT (Cns_MAX_LENGTH_SUBJECT*Str_MAX_CHARACTER) #define Cns_MAX_BYTES_SUBJECT (Cns_MAX_LENGTH_SUBJECT * Str_MAX_CHARACTER)
#define Cns_MAX_BYTES_TEXT ( 64*1024-1) // Used for subjects and other medium texts #define Cns_MAX_BYTES_TEXT ( 64*1024 - 1) // Used for subjects and other medium texts
#define Cns_MAX_BYTES_LONG_TEXT (256*1024-1) // Used for big contents #define Cns_MAX_BYTES_LONG_TEXT (256*1024 - 1) // Used for big contents
#define Cns_MAX_LENGTH_STRING 127 #define Cns_MAX_LENGTH_STRING (128 - 1)
#define Cns_MAX_BYTES_STRING 127 #define Cns_MAX_BYTES_STRING (128 - 1)
#define Cns_MAX_LENGTH_URL 127 #define Cns_MAX_LENGTH_URL (128 - 1)
#define Cns_MAX_BYTES_URL 255 #define Cns_MAX_BYTES_URL (256 - 1)
/*****************************************************************************/ /*****************************************************************************/
/******************************* Public types ********************************/ /******************************* Public types ********************************/

View File

@ -6,7 +6,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as
@ -1049,7 +1049,9 @@ void Cty_GetListCountries (Cty_GetExtraData_t GetExtraData)
Cty->NumUsrs = 0; Cty->NumUsrs = 0;
/* Get the name of the country in current language */ /* Get the name of the country in current language */
strcpy (Cty->Name[Gbl.Prefs.Language],row[2]); strncpy (Cty->Name[Gbl.Prefs.Language],row[2],
Cty_MAX_BYTES_COUNTRY_NAME);
Cty->Name[Gbl.Prefs.Language][Cty_MAX_BYTES_COUNTRY_NAME] = '\0';
break; break;
case Cty_GET_EXTRA_DATA: case Cty_GET_EXTRA_DATA:
/* Get the name of the country in several languages */ /* Get the name of the country in several languages */
@ -1057,8 +1059,13 @@ void Cty_GetListCountries (Cty_GetExtraData_t GetExtraData)
Lan <= Txt_NUM_LANGUAGES; Lan <= Txt_NUM_LANGUAGES;
Lan++) Lan++)
{ {
strcpy (Cty->Name[Lan],row[1+Lan]); strncpy (Cty->Name[Lan],row[1 + Lan],
strcpy (Cty->WWW[Lan],row[1+Txt_NUM_LANGUAGES+Lan]); Cty_MAX_BYTES_COUNTRY_NAME);
Cty->Name[Lan][Cty_MAX_BYTES_COUNTRY_NAME] = '\0';
strncpy (Cty->WWW[Lan],row[1 + Txt_NUM_LANGUAGES + Lan],
Cns_MAX_LENGTH_WWW);
Cty->WWW[Lan][Cns_MAX_LENGTH_WWW] = '\0';
} }
/* Get number of users who claim to belong to this country */ /* Get number of users who claim to belong to this country */
@ -1223,7 +1230,11 @@ bool Cty_GetDataOfCountryByCod (struct Country *Cty,Cty_GetExtraData_t GetExtraD
Lan <= Txt_NUM_LANGUAGES; Lan <= Txt_NUM_LANGUAGES;
Lan++) Lan++)
if (Lan == Gbl.Prefs.Language) if (Lan == Gbl.Prefs.Language)
strcpy (Cty->Name[Lan],Txt_Another_country); {
strncpy (Cty->Name[Lan],Txt_Another_country,
Cty_MAX_BYTES_COUNTRY_NAME);
Cty->Name[Lan][Cty_MAX_BYTES_COUNTRY_NAME] = '\0';
}
else else
Cty->Name[Lan][0] = '\0'; Cty->Name[Lan][0] = '\0';
return false; return false;
@ -1294,8 +1305,12 @@ bool Cty_GetDataOfCountryByCod (struct Country *Cty,Cty_GetExtraData_t GetExtraD
{ {
case Cty_GET_BASIC_DATA: case Cty_GET_BASIC_DATA:
/* Get name and WWW of the country in current language */ /* Get name and WWW of the country in current language */
strcpy (Cty->Name[Gbl.Prefs.Language],row[1]); strncpy (Cty->Name[Gbl.Prefs.Language],row[1],
strcpy (Cty->WWW [Gbl.Prefs.Language],row[2]); Cty_MAX_BYTES_COUNTRY_NAME);
Cty->Name[Gbl.Prefs.Language][Cty_MAX_BYTES_COUNTRY_NAME] = '\0';
strncpy (Cty->WWW[Gbl.Prefs.Language],row[2],Cns_MAX_LENGTH_WWW);
Cty->WWW[Gbl.Prefs.Language][Cns_MAX_LENGTH_WWW] = '\0';
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 */
@ -1303,8 +1318,13 @@ bool Cty_GetDataOfCountryByCod (struct Country *Cty,Cty_GetExtraData_t GetExtraD
Lan <= Txt_NUM_LANGUAGES; Lan <= Txt_NUM_LANGUAGES;
Lan++) Lan++)
{ {
strcpy (Cty->Name[Lan],row[Lan]); strncpy (Cty->Name[Lan],row[Lan],
strcpy (Cty->WWW[Lan],row[Txt_NUM_LANGUAGES+Lan]); Cty_MAX_BYTES_COUNTRY_NAME);
Cty->Name[Lan][Cty_MAX_BYTES_COUNTRY_NAME] = '\0';
strncpy (Cty->WWW[Lan],row[Txt_NUM_LANGUAGES + Lan],
Cns_MAX_LENGTH_WWW);
Cty->WWW[Lan][Cns_MAX_LENGTH_WWW] = '\0';
} }
/* Get number of users who claim to belong to this country */ /* Get number of users who claim to belong to this country */
@ -1373,6 +1393,7 @@ static void Cty_GetMapAttribution (long CtyCod,char **MapAttribution)
char Query[128]; char Query[128];
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
MYSQL_ROW row; MYSQL_ROW row;
size_t Length;
/***** Free possible former map attribution *****/ /***** Free possible former map attribution *****/
Cty_FreeMapAttribution (MapAttribution); Cty_FreeMapAttribution (MapAttribution);
@ -1389,9 +1410,11 @@ static void Cty_GetMapAttribution (long CtyCod,char **MapAttribution)
if (row[0]) if (row[0])
if (row[0][0]) if (row[0][0])
{ {
if (((*MapAttribution) = (char *) malloc (strlen (row[0])+1)) == NULL) Length = strlen (row[0]);
if (((*MapAttribution) = (char *) malloc (Length + 1)) == NULL)
Lay_ShowErrorAndExit ("Error allocating memory for map attribution."); Lay_ShowErrorAndExit ("Error allocating memory for map attribution.");
strcpy (*MapAttribution,row[0]); strncpy (*MapAttribution,row[0],Length);
MapAttribution[Length] = '\0';
} }
} }
@ -1532,7 +1555,7 @@ static void Cty_ListCountriesForEdition (void)
" maxlength=\"%u\" value=\"%s\"" " maxlength=\"%u\" value=\"%s\""
" class=\"INPUT_WWW\"" " class=\"INPUT_WWW\""
" onchange=\"document.getElementById('%s').submit();\" />", " onchange=\"document.getElementById('%s').submit();\" />",
Cty_MAX_LENGTH_COUNTRY_WWW, Cns_MAX_LENGTH_WWW,
Cty->WWW[Lan],Gbl.Form.Id); Cty->WWW[Lan],Gbl.Form.Id);
Act_FormEnd (); Act_FormEnd ();
fprintf (Gbl.F.Out,"</td>" fprintf (Gbl.F.Out,"</td>"
@ -1700,7 +1723,8 @@ void Cty_RenameCountry (void)
} }
/***** Show the form again *****/ /***** Show the form again *****/
strcpy (Cty->Name[Language],NewCtyName); strncpy (Cty->Name[Language],NewCtyName,Cty_MAX_BYTES_COUNTRY_NAME);
Cty->Name[Language][Cty_MAX_BYTES_COUNTRY_NAME] = '\0';
Cty_EditCountries (); Cty_EditCountries ();
} }
@ -1756,9 +1780,9 @@ void Cty_ChangeCtyWWW (void)
{ {
extern const char *Txt_The_new_web_address_is_X; extern const char *Txt_The_new_web_address_is_X;
extern const char *Txt_STR_LANG_ID[1+Txt_NUM_LANGUAGES]; extern const char *Txt_STR_LANG_ID[1+Txt_NUM_LANGUAGES];
char Query[256+Cty_MAX_LENGTH_COUNTRY_WWW]; char Query[256+Cns_MAX_LENGTH_WWW];
struct Country *Cty; struct Country *Cty;
char NewWWW[Cty_MAX_LENGTH_COUNTRY_WWW+1]; char NewWWW[Cns_MAX_LENGTH_WWW+1];
Txt_Language_t Language; Txt_Language_t Language;
Cty = &Gbl.Ctys.EditingCty; Cty = &Gbl.Ctys.EditingCty;
@ -1787,7 +1811,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 *****/
strcpy (Cty->WWW[Language],NewWWW); strncpy (Cty->WWW[Language],NewWWW,Cns_MAX_LENGTH_WWW);
Cty->WWW[Language][Cns_MAX_LENGTH_WWW] = '\0';
Cty_EditCountries (); Cty_EditCountries ();
} }
@ -1909,7 +1934,7 @@ static void Cty_PutFormToCreateCountry (void)
"</td>" "</td>"
"</tr>", "</tr>",
Txt_STR_LANG_ID[Lan], Txt_STR_LANG_ID[Lan],
Cty_MAX_LENGTH_COUNTRY_WWW, Cns_MAX_LENGTH_WWW,
Cty->WWW[Lan]); Cty->WWW[Lan]);
} }
@ -2053,7 +2078,7 @@ void Cty_RecFormNewCountry (void)
} }
sprintf (ParamName,"WWW_%s",Txt_STR_LANG_ID[Lan]); sprintf (ParamName,"WWW_%s",Txt_STR_LANG_ID[Lan]);
Par_GetParToText (ParamName,Cty->WWW[Lan],Cty_MAX_LENGTH_COUNTRY_WWW); Par_GetParToText (ParamName,Cty->WWW[Lan],Cns_MAX_LENGTH_WWW);
} }
} }
} }
@ -2079,8 +2104,8 @@ static void Cty_CreateCountry (struct Country *Cty)
char SubQueryNam1[(1+Txt_NUM_LANGUAGES)*32]; char SubQueryNam1[(1+Txt_NUM_LANGUAGES)*32];
char SubQueryNam2[(1+Txt_NUM_LANGUAGES)*Cty_MAX_BYTES_COUNTRY_NAME]; char SubQueryNam2[(1+Txt_NUM_LANGUAGES)*Cty_MAX_BYTES_COUNTRY_NAME];
char SubQueryWWW1[(1+Txt_NUM_LANGUAGES)*32]; char SubQueryWWW1[(1+Txt_NUM_LANGUAGES)*32];
char SubQueryWWW2[(1+Txt_NUM_LANGUAGES)*Cty_MAX_LENGTH_COUNTRY_WWW]; char SubQueryWWW2[(1+Txt_NUM_LANGUAGES)*Cns_MAX_LENGTH_WWW];
char Query[1024+(1+Txt_NUM_LANGUAGES)*(32+Cty_MAX_BYTES_COUNTRY_NAME+32+Cty_MAX_LENGTH_COUNTRY_WWW)]; char Query[1024 + (1 + Txt_NUM_LANGUAGES) * (32 + Cty_MAX_BYTES_COUNTRY_NAME + 32 + Cns_MAX_LENGTH_WWW)];
/***** Create a new country *****/ /***** Create a new country *****/
SubQueryNam1[0] = '\0'; SubQueryNam1[0] = '\0';

View File

@ -8,7 +8,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as
@ -38,7 +38,6 @@
/*****************************************************************************/ /*****************************************************************************/
#define Cty_MAX_BYTES_COUNTRY_NAME 255 #define Cty_MAX_BYTES_COUNTRY_NAME 255
#define Cty_MAX_LENGTH_COUNTRY_WWW 255
#define Cty_MAX_LENGTH_MAP_ATTRIBUTION (4*1024) #define Cty_MAX_LENGTH_MAP_ATTRIBUTION (4*1024)
#define Cty_MAX_COUNTRS_PER_USR 10 // Used in list of my countries #define Cty_MAX_COUNTRS_PER_USR 10 // Used in list of my countries
@ -46,9 +45,9 @@
struct Country struct Country
{ {
long CtyCod; long CtyCod;
char Alpha2[2+1]; char Alpha2[2 + 1];
char Name[1+Txt_NUM_LANGUAGES][Cty_MAX_BYTES_COUNTRY_NAME+1]; char Name[1 + Txt_NUM_LANGUAGES][Cty_MAX_BYTES_COUNTRY_NAME + 1];
char WWW [1+Txt_NUM_LANGUAGES][Cty_MAX_LENGTH_COUNTRY_WWW+1]; char WWW [1 + Txt_NUM_LANGUAGES][Cns_MAX_LENGTH_WWW + 1];
unsigned NumUsrsWhoClaimToBelongToCty; unsigned NumUsrsWhoClaimToBelongToCty;
unsigned NumInss; unsigned NumInss;
unsigned NumCtrs; unsigned NumCtrs;

View File

@ -6,7 +6,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as
@ -105,6 +105,10 @@ static void Crs_UpdateCrsDegDB (long CrsCod,long DegCod);
static void Crs_UpdateCrsYear (struct Course *Crs,unsigned NewYear); static void Crs_UpdateCrsYear (struct Course *Crs,unsigned NewYear);
static void Crs_GetShortNamesByCod (long CrsCod,
char CrsShortName[Crs_MAX_LENGTH_COURSE_SHRT_NAME + 1],
char DegShortName[Deg_MAX_LENGTH_DEGREE_SHRT_NAME + 1]);
static void Crs_EmptyCourseCompletely (long CrsCod); static void Crs_EmptyCourseCompletely (long CrsCod);
static void Crs_RenameCourse (struct Course *Crs,Cns_ShrtOrFullName_t ShrtOrFullName); static void Crs_RenameCourse (struct Course *Crs,Cns_ShrtOrFullName_t ShrtOrFullName);
@ -516,11 +520,11 @@ static void Crs_WriteListMyCoursesToSelectOne (void)
struct Centre Ctr; struct Centre Ctr;
struct Degree Deg; struct Degree Deg;
struct Course Crs; struct Course Crs;
char InsFullName[Ins_MAX_LENGTH_INSTIT_FULL_NAME+1]; char InsFullName[Ins_MAX_LENGTH_INSTIT_FULL_NAME + 1];
char CtrFullName[Ctr_MAX_LENGTH_CENTRE_FULL_NAME+1]; char CtrFullName[Ctr_MAX_LENGTH_CENTRE_FULL_NAME + 1];
char DegFullName[Deg_MAX_LENGTH_DEGREE_FULL_NAME+1]; char DegFullName[Deg_MAX_LENGTH_DEGREE_FULL_NAME + 1];
char CrsFullName[Crs_MAX_LENGTH_COURSE_FULL_NAME+1]; char CrsFullName[Crs_MAX_LENGTH_COURSE_FULL_NAME + 1];
bool IsLastItemInLevel[1+5]; bool IsLastItemInLevel[1 + 5];
bool Highlight; // Highlight because degree, course, etc. is selected bool Highlight; // Highlight because degree, course, etc. is selected
MYSQL_RES *mysql_resCty; MYSQL_RES *mysql_resCty;
MYSQL_RES *mysql_resIns; MYSQL_RES *mysql_resIns;
@ -540,10 +544,10 @@ static void Crs_WriteListMyCoursesToSelectOne (void)
unsigned NumCrss; unsigned NumCrss;
char ActTxt[Act_MAX_LENGTH_ACTION_TXT+1]; char ActTxt[Act_MAX_LENGTH_ACTION_TXT+1];
char PathRelRSSFile[PATH_MAX+1]; char PathRelRSSFile[PATH_MAX+1];
char ClassNormal[64]; const char *ClassNormal;
char ClassHighlight[64]; char ClassHighlight[64];
strcpy (ClassNormal,The_ClassForm[Gbl.Prefs.Theme]); ClassNormal = The_ClassForm[Gbl.Prefs.Theme];
sprintf (ClassHighlight,"%s LIGHT_BLUE",The_ClassFormDark[Gbl.Prefs.Theme]); sprintf (ClassHighlight,"%s LIGHT_BLUE",The_ClassFormDark[Gbl.Prefs.Theme]);
/***** Table start *****/ /***** Table start *****/
@ -639,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);
strcpy (InsFullName,Ins.FullName); strncpy (InsFullName,Ins.FullName,Ins_MAX_LENGTH_INSTIT_FULL_NAME);
InsFullName[Ins_MAX_LENGTH_INSTIT_FULL_NAME] = '\0';
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 ();
@ -674,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);
strcpy (CtrFullName,Ctr.FullName); strncpy (CtrFullName,Ctr.FullName,Ctr_MAX_LENGTH_CENTRE_FULL_NAME);
CtrFullName[Ctr_MAX_LENGTH_CENTRE_FULL_NAME] = '\0';
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 ();
@ -709,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);
strcpy (DegFullName,Deg.FullName); strncpy (DegFullName,Deg.FullName,Deg_MAX_LENGTH_DEGREE_FULL_NAME);
DegFullName[Deg_MAX_LENGTH_DEGREE_FULL_NAME] = '\0';
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 ();
@ -749,7 +756,8 @@ static void Crs_WriteListMyCoursesToSelectOne (void)
Gbl.Prefs.IconsURL, Gbl.Prefs.IconsURL,
Crs.ShrtName, Crs.ShrtName,
Crs.FullName); Crs.FullName);
strcpy (CrsFullName,Crs.FullName); strncpy (CrsFullName,Crs.FullName,Crs_MAX_LENGTH_COURSE_FULL_NAME);
CrsFullName[Crs_MAX_LENGTH_COURSE_FULL_NAME] = '\0';
Str_LimitLengthHTMLStr (CrsFullName,Crs_MAX_BYTES_TXT_LINK); Str_LimitLengthHTMLStr (CrsFullName,Crs_MAX_BYTES_TXT_LINK);
fprintf (Gbl.F.Out,"&nbsp;%s</a>",CrsFullName); fprintf (Gbl.F.Out,"&nbsp;%s</a>",CrsFullName);
Act_FormEnd (); Act_FormEnd ();
@ -1091,8 +1099,8 @@ void Crs_WriteSelectorMyCourses (void)
long CrsCod; long CrsCod;
long DegCod; long DegCod;
long LastDegCod; long LastDegCod;
char CrsShortName[Crs_MAX_LENGTH_COURSE_SHRT_NAME+1]; char CrsShortName[Crs_MAX_LENGTH_COURSE_SHRT_NAME + 1];
char DegShortName[Deg_MAX_LENGTH_DEGREE_SHRT_NAME+1]; char DegShortName[Deg_MAX_LENGTH_DEGREE_SHRT_NAME + 1];
/***** Fill the list with the courses I belong to, if not filled *****/ /***** Fill the list with the courses I belong to, if not filled *****/
if (Gbl.Usrs.Me.Logged) if (Gbl.Usrs.Me.Logged)
@ -2130,7 +2138,9 @@ static void Crs_GetDataOfCourseFromRow (struct Course *Crs,MYSQL_ROW row)
/******* Get the short names of degree and course from a course code *********/ /******* Get the short names of degree and course from a course code *********/
/*****************************************************************************/ /*****************************************************************************/
void Crs_GetShortNamesByCod (long CrsCod,char *CrsShortName,char *DegShortName) static void Crs_GetShortNamesByCod (long CrsCod,
char CrsShortName[Crs_MAX_LENGTH_COURSE_SHRT_NAME + 1],
char DegShortName[Deg_MAX_LENGTH_DEGREE_SHRT_NAME + 1])
{ {
char Query[512]; char Query[512];
MYSQL_RES *mysql_res; MYSQL_RES *mysql_res;
@ -2150,8 +2160,12 @@ void Crs_GetShortNamesByCod (long CrsCod,char *CrsShortName,char *DegShortName)
{ {
/***** 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);
strcpy (CrsShortName,row[0]);
strcpy (DegShortName,row[1]); strncpy (CrsShortName,row[0],Crs_MAX_LENGTH_COURSE_SHRT_NAME);
CrsShortName[Crs_MAX_LENGTH_COURSE_SHRT_NAME] = '\0';
strncpy (DegShortName,row[1],Deg_MAX_LENGTH_DEGREE_SHRT_NAME);
DegShortName[Deg_MAX_LENGTH_DEGREE_SHRT_NAME] = '\0';
} }
/***** Free structure that stores the query result *****/ /***** Free structure that stores the query result *****/
@ -2376,7 +2390,9 @@ void Crs_ChangeInsCrsCod (void)
else else
{ {
Gbl.Error = true; Gbl.Error = true;
strcpy (Gbl.Message,Txt_You_dont_have_permission_to_edit_this_course); strncpy (Gbl.Message,Txt_You_dont_have_permission_to_edit_this_course,
Lay_MAX_BYTES_ALERT);
Gbl.Message[Lay_MAX_BYTES_ALERT] = '\0';
} }
} }
@ -2582,7 +2598,9 @@ void Crs_ChangeCrsYear (void)
else else
{ {
Gbl.Error = true; Gbl.Error = true;
strcpy (Gbl.Message,Txt_You_dont_have_permission_to_edit_this_course); strncpy (Gbl.Message,Txt_You_dont_have_permission_to_edit_this_course,
Lay_MAX_BYTES_ALERT);
Gbl.Message[Lay_MAX_BYTES_ALERT] = '\0';
} }
} }
@ -2738,7 +2756,9 @@ static void Crs_RenameCourse (struct Course *Crs,Cns_ShrtOrFullName_t ShrtOrFull
else else
{ {
Gbl.Error = true; Gbl.Error = true;
strcpy (Gbl.Message,Txt_You_dont_have_permission_to_edit_this_course); strncpy (Gbl.Message,Txt_You_dont_have_permission_to_edit_this_course,
Lay_MAX_BYTES_ALERT);
Gbl.Message[Lay_MAX_BYTES_ALERT] = '\0';
} }
} }

View File

@ -8,7 +8,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as
@ -39,9 +39,9 @@
#define Crs_MAX_COURSES_PER_USR 100 // Used in list of my courses and list of distinct courses in sent or received messages #define Crs_MAX_COURSES_PER_USR 100 // Used in list of my courses and list of distinct courses in sent or received messages
#define Crs_LENGTH_INSTITUTIONAL_CRS_COD 7 #define Crs_LENGTH_INSTITUTIONAL_CRS_COD 7
#define Crs_MAX_LENGTH_COURSE_SHRT_NAME 32 #define Crs_MAX_LENGTH_COURSE_SHRT_NAME 32
#define Crs_MAX_LENGTH_COURSE_FULL_NAME 127 #define Crs_MAX_LENGTH_COURSE_FULL_NAME (128 - 1)
#define Crs_MIN_MONTHS_WITHOUT_ACCESS_TO_REMOVE_OLD_CRSS 6 #define Crs_MIN_MONTHS_WITHOUT_ACCESS_TO_REMOVE_OLD_CRSS 6
#define Crs_DEF_MONTHS_WITHOUT_ACCESS_TO_REMOVE_OLD_CRSS 12 #define Crs_DEF_MONTHS_WITHOUT_ACCESS_TO_REMOVE_OLD_CRSS 12
@ -115,7 +115,6 @@ void Crs_RecFormNewCrs (void);
void Crs_RemoveCourse (void); void Crs_RemoveCourse (void);
bool Crs_GetDataOfCourseByCod (struct Course *Crs); bool Crs_GetDataOfCourseByCod (struct Course *Crs);
void Crs_GetShortNamesByCod (long CrsCod,char *CrsShortName,char *DegShortName);
void Crs_RemoveCourseCompletely (long CrsCod); void Crs_RemoveCourseCompletely (long CrsCod);
void Crs_ChangeInsCrsCodInConfig (void); void Crs_ChangeInsCrsCodInConfig (void);
void Crs_ChangeInsCrsCod (void); void Crs_ChangeInsCrsCod (void);

View File

@ -6,7 +6,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as

View File

@ -8,7 +8,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as

View File

@ -6,7 +6,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as

View File

@ -8,7 +8,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as

View File

@ -6,7 +6,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as
@ -142,8 +142,8 @@ bool Dat_GetDateFromYYYYMMDD (struct Date *Date,const char *YYYYMMDD)
{ {
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)
{ {
strncpy (Date->YYYYMMDD,YYYYMMDD,4+2+2); strncpy (Date->YYYYMMDD,YYYYMMDD,Dat_LENGTH_YYYYMMDD);
Date->YYYYMMDD[4+2+2] = '\0'; Date->YYYYMMDD[Dat_LENGTH_YYYYMMDD] = '\0';
return true; return true;
} }
else else
@ -1263,7 +1263,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;
strcpy (DateDst->YYYYMMDD,DateSrc->YYYYMMDD); strncpy (DateDst->YYYYMMDD,DateSrc->YYYYMMDD,Dat_LENGTH_YYYYMMDD);
DateDst->YYYYMMDD[Dat_LENGTH_YYYYMMDD] = '\0';
} }
/*****************************************************************************/ /*****************************************************************************/

View File

@ -8,7 +8,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as
@ -43,13 +43,14 @@
/******************************* Public types ********************************/ /******************************* Public types ********************************/
/*****************************************************************************/ /*****************************************************************************/
#define Dat_LENGTH_YYYYMMDD (4 + 2 + 2)
struct Date struct Date
{ {
unsigned Day; unsigned Day;
unsigned Month; unsigned Month;
unsigned Year; unsigned Year;
unsigned Week; unsigned Week;
char YYYYMMDD[4+2+2+1]; char YYYYMMDD[Dat_LENGTH_YYYYMMDD + 1];
}; };
struct Time struct Time
{ {

View File

@ -6,7 +6,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as
@ -1738,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]) *****/
strcpy (Deg->ShrtName,row[5]); strncpy (Deg->ShrtName,row[5],Deg_MAX_LENGTH_DEGREE_SHRT_NAME);
Deg->ShrtName[Deg_MAX_LENGTH_DEGREE_SHRT_NAME] = '\0';
/***** Get degree full name (row[6]) *****/ /***** Get degree full name (row[6]) *****/
strcpy (Deg->FullName,row[6]); strncpy (Deg->FullName,row[6],Deg_MAX_LENGTH_DEGREE_FULL_NAME);
Deg->FullName[Deg_MAX_LENGTH_DEGREE_FULL_NAME] = '\0';
/***** Get WWW (row[7]) *****/ /***** Get WWW (row[7]) *****/
strcpy (Deg->WWW,row[7]); strncpy (Deg->WWW,row[7],Cns_MAX_LENGTH_WWW);
Deg->WWW[Cns_MAX_LENGTH_WWW] = '\0';
} }
/*****************************************************************************/ /*****************************************************************************/
@ -1768,7 +1771,9 @@ 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);
strcpy (Deg->ShrtName,row[0]);
strncpy (Deg->ShrtName,row[0],Deg_MAX_LENGTH_DEGREE_SHRT_NAME);
Deg->ShrtName[Deg_MAX_LENGTH_DEGREE_SHRT_NAME] = '\0';
} }
/***** Free structure that stores the query result *****/ /***** Free structure that stores the query result *****/
@ -2138,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);
strcpy (Deg->WWW,NewWWW); strncpy (Deg->WWW,NewWWW,Cns_MAX_LENGTH_WWW);
Deg->WWW[Cns_MAX_LENGTH_WWW] = '\0';
/***** 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);
@ -2169,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);
strcpy (Gbl.CurrentDeg.Deg.WWW,NewWWW); strncpy (Gbl.CurrentDeg.Deg.WWW,NewWWW,Cns_MAX_LENGTH_WWW);
Gbl.CurrentDeg.Deg.WWW[Cns_MAX_LENGTH_WWW] = '\0';
/***** 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

@ -8,7 +8,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as
@ -36,15 +36,15 @@
/***************************** Public constants ******************************/ /***************************** Public constants ******************************/
/*****************************************************************************/ /*****************************************************************************/
#define Deg_MAX_YEARS_PER_DEGREE 12 // Max number of academic years per degree #define Deg_MAX_YEARS_PER_DEGREE 12 // Max number of academic years per degree
#define Deg_MAX_DEGREES_PER_USR 20 // Used in list of my degrees #define Deg_MAX_DEGREES_PER_USR 20 // Used in list of my degrees
#define Deg_MAX_LENGTH_DEGREE_SHRT_NAME 32 #define Deg_MAX_LENGTH_DEGREE_SHRT_NAME 32
#define Deg_MAX_LENGTH_DEGREE_FULL_NAME 127 #define Deg_MAX_LENGTH_DEGREE_FULL_NAME (128 - 1)
#define Deg_MAX_LENGTH_LOCATION_SHORT_NAME 32 #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) #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 ********************************/
@ -73,9 +73,9 @@ struct Degree
long CtrCod; // Centre code long CtrCod; // Centre code
Deg_Status_t Status; // Degree status Deg_Status_t Status; // Degree status
long RequesterUsrCod; // User code of the person who requested the creation of this degree long RequesterUsrCod; // User code of the person who requested the creation of this degree
char ShrtName[Deg_MAX_LENGTH_DEGREE_SHRT_NAME+1]; // Short name of degree char ShrtName[Deg_MAX_LENGTH_DEGREE_SHRT_NAME + 1]; // Short name of degree
char FullName[Deg_MAX_LENGTH_DEGREE_FULL_NAME+1]; // Full name of degree char FullName[Deg_MAX_LENGTH_DEGREE_FULL_NAME + 1]; // Full name of degree
char WWW[Cns_MAX_LENGTH_WWW+1]; char WWW[Cns_MAX_LENGTH_WWW + 1];
struct Course *LstCrss; // List of courses in this degree struct Course *LstCrss; // List of courses in this degree
}; };

View File

@ -6,7 +6,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as
@ -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]) */
strcpy (DegTyp->DegTypName,row[0]); strncpy (DegTyp->DegTypName,row[0],Deg_MAX_LENGTH_DEGREE_TYPE_NAME);
DegTyp->DegTypName[Deg_MAX_LENGTH_DEGREE_TYPE_NAME] = '\0';
/* 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 *****/
strcpy (DegTyp->DegTypName,NewNameDegTyp); strncpy (DegTyp->DegTypName,NewNameDegTyp,Deg_MAX_LENGTH_DEGREE_TYPE_NAME);
DegTyp->DegTypName[Deg_MAX_LENGTH_DEGREE_TYPE_NAME] = '\0';
DT_ReqEditDegreeTypes (); DT_ReqEditDegreeTypes ();
} }

View File

@ -8,7 +8,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as
@ -39,9 +39,9 @@
struct DegreeType struct DegreeType
{ {
long DegTypCod; // Degree type code long DegTypCod; // Degree type code
char DegTypName[Deg_MAX_LENGTH_DEGREE_TYPE_NAME+1]; // Degree type name char DegTypName[Deg_MAX_LENGTH_DEGREE_TYPE_NAME + 1]; // Degree type name
unsigned NumDegs; // Number of degrees of this type unsigned NumDegs; // Number of degrees of this type
}; };
/*****************************************************************************/ /*****************************************************************************/

View File

@ -6,7 +6,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as
@ -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]) */
strcpy (Dpt->ShrtName,row[2]); strncpy (Dpt->ShrtName,row[2],MAX_LENGTH_DEPARTMENT_SHRT_NAME);
Dpt->ShrtName[MAX_LENGTH_DEPARTMENT_SHRT_NAME] = '\0';
/* Get the full name of the department (row[3]) */ /* Get the full name of the department (row[3]) */
strcpy (Dpt->FullName,row[3]); strncpy (Dpt->FullName,row[3],MAX_LENGTH_DEPARTMENT_FULL_NAME);
Dpt->FullName[MAX_LENGTH_DEPARTMENT_FULL_NAME] = '\0';
/* Get the URL of the department (row[4]) */ /* Get the URL of the department (row[4]) */
strcpy (Dpt->WWW,row[4]); strncpy (Dpt->WWW,row[4],Cns_MAX_LENGTH_WWW);
Dpt->WWW[Cns_MAX_LENGTH_WWW] = '\0';
/* 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)
@ -391,8 +394,11 @@ void Dpt_GetDataOfDepartmentByCod (struct Department *Dpt)
/***** Check if department code is correct *****/ /***** Check if department code is correct *****/
if (Dpt->DptCod == 0) if (Dpt->DptCod == 0)
{ {
strcpy (Dpt->ShrtName,Txt_Another_department); strncpy (Dpt->ShrtName,Txt_Another_department,MAX_LENGTH_DEPARTMENT_SHRT_NAME);
strcpy (Dpt->FullName,Txt_Another_department); Dpt->ShrtName[MAX_LENGTH_DEPARTMENT_SHRT_NAME] = '\0';
strncpy (Dpt->FullName,Txt_Another_department,MAX_LENGTH_DEPARTMENT_FULL_NAME);
Dpt->FullName[MAX_LENGTH_DEPARTMENT_FULL_NAME] = '\0';
} }
else if (Dpt->DptCod > 0) else if (Dpt->DptCod > 0)
{ {
@ -424,13 +430,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]) */
strcpy (Dpt->ShrtName,row[1]); strncpy (Dpt->ShrtName,row[1],MAX_LENGTH_DEPARTMENT_SHRT_NAME);
Dpt->ShrtName[MAX_LENGTH_DEPARTMENT_SHRT_NAME] = '\0';
/* Get the full name of the department (row[2]) */ /* Get the full name of the department (row[2]) */
strcpy (Dpt->FullName,row[2]); strncpy (Dpt->FullName,row[2],MAX_LENGTH_DEPARTMENT_FULL_NAME);
Dpt->FullName[MAX_LENGTH_DEPARTMENT_FULL_NAME] = '\0';
/* Get the URL of the department (row[3]) */ /* Get the URL of the department (row[3]) */
strcpy (Dpt->WWW,row[3]); strncpy (Dpt->WWW,row[3],Cns_MAX_LENGTH_WWW);
Dpt->WWW[Cns_MAX_LENGTH_WWW] = '\0';
/* 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)
@ -716,9 +725,9 @@ static void Dpt_RenameDepartment (Cns_ShrtOrFullName_t ShrtOrFullName)
struct Department *Dpt; struct Department *Dpt;
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 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[MAX_LENGTH_DEPARTMENT_FULL_NAME + 1];
Dpt = &Gbl.Dpts.EditingDpt; Dpt = &Gbl.Dpts.EditingDpt;
switch (ShrtOrFullName) switch (ShrtOrFullName)
@ -789,7 +798,8 @@ static void Dpt_RenameDepartment (Cns_ShrtOrFullName_t ShrtOrFullName)
} }
/***** Show the form again *****/ /***** Show the form again *****/
strcpy (CurrentDptName,NewDptName); strncpy (CurrentDptName,NewDptName,MaxLength);
CurrentDptName[MaxLength] = '\0';
Dpt_EditDepartments (); Dpt_EditDepartments ();
} }
@ -850,7 +860,8 @@ void Dpt_ChangeDptWWW (void)
} }
/***** Show the form again *****/ /***** Show the form again *****/
strcpy (Dpt->WWW,NewWWW); strncpy (Dpt->WWW,NewWWW,Cns_MAX_LENGTH_WWW);
Dpt->WWW[Cns_MAX_LENGTH_WWW] = '\0';
Dpt_EditDepartments (); Dpt_EditDepartments ();
} }

View File

@ -8,7 +8,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as
@ -32,15 +32,15 @@
/*****************************************************************************/ /*****************************************************************************/
#define MAX_LENGTH_DEPARTMENT_SHRT_NAME 32 #define MAX_LENGTH_DEPARTMENT_SHRT_NAME 32
#define MAX_LENGTH_DEPARTMENT_FULL_NAME 255 #define 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[MAX_LENGTH_DEPARTMENT_SHRT_NAME + 1];
char FullName[MAX_LENGTH_DEPARTMENT_FULL_NAME+1]; char FullName[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

@ -6,7 +6,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General 3 License as it under the terms of the GNU Affero General 3 License as

View File

@ -8,7 +8,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as

View File

@ -6,7 +6,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General 3 License as it under the terms of the GNU Affero General 3 License as
@ -359,7 +359,7 @@ void Enr_ReqAcceptRegisterInCrs (void)
/*****************************************************************************/ /*****************************************************************************/
// This function may be called inside a web service, so don't report error // This function may be called inside a web service, so don't report error
void Enr_GetNotifEnrollment (char *SummaryStr, void Enr_GetNotifEnrollment (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],
long CrsCod,long UsrCod, long CrsCod,long UsrCod,
unsigned MaxChars) unsigned MaxChars)
{ {
@ -396,7 +396,8 @@ void Enr_GetNotifEnrollment (char *SummaryStr,
/* Role (row[0]) */ /* Role (row[0]) */
Role = Rol_ConvertUnsignedStrToRole (row[0]); Role = Rol_ConvertUnsignedStrToRole (row[0]);
strcpy (SummaryStr,Txt_ROLES_SINGUL_Abc[Role][UsrDat.Sex]); strncpy (SummaryStr,Txt_ROLES_SINGUL_Abc[Role][UsrDat.Sex],Cns_MAX_BYTES_TEXT);
SummaryStr[Cns_MAX_BYTES_TEXT] = '\0';
if (MaxChars) if (MaxChars)
Str_LimitLengthHTMLStr (SummaryStr,MaxChars); Str_LimitLengthHTMLStr (SummaryStr,MaxChars);
@ -1936,7 +1937,7 @@ void Enr_SignUpInCrs (void)
/*****************************************************************************/ /*****************************************************************************/
// This function may be called inside a web service, so don't report error // This function may be called inside a web service, so don't report error
void Enr_GetNotifEnrollmentRequest (char *SummaryStr,char **ContentStr, void Enr_GetNotifEnrollmentRequest (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],char **ContentStr,
long ReqCod,unsigned MaxChars,bool GetContent) long ReqCod,unsigned MaxChars,bool GetContent)
{ {
extern const char *Txt_ROLES_SINGUL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS]; extern const char *Txt_ROLES_SINGUL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
@ -1972,7 +1973,8 @@ void Enr_GetNotifEnrollmentRequest (char *SummaryStr,char **ContentStr,
/* Role (row[1]) */ /* Role (row[1]) */
DesiredRole = Rol_ConvertUnsignedStrToRole (row[1]); DesiredRole = Rol_ConvertUnsignedStrToRole (row[1]);
strcpy (SummaryStr,Txt_ROLES_SINGUL_Abc[DesiredRole][UsrDat.Sex]); strncpy (SummaryStr,Txt_ROLES_SINGUL_Abc[DesiredRole][UsrDat.Sex],Cns_MAX_BYTES_TEXT);
SummaryStr[Cns_MAX_BYTES_TEXT] = '\0';
if (MaxChars) if (MaxChars)
Str_LimitLengthHTMLStr (SummaryStr,MaxChars); Str_LimitLengthHTMLStr (SummaryStr,MaxChars);

View File

@ -8,7 +8,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as
@ -79,7 +79,7 @@ void Enr_RegisterUsrInCurrentCrs (struct UsrData *UsrDat,Rol_Role_t NewRole,
void Enr_WriteFormToReqAnotherUsrID (Act_Action_t NextAction); void Enr_WriteFormToReqAnotherUsrID (Act_Action_t NextAction);
void Enr_ReqAcceptRegisterInCrs (void); void Enr_ReqAcceptRegisterInCrs (void);
void Enr_GetNotifEnrollment (char *SummaryStr, void Enr_GetNotifEnrollment (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],
long CrsCod,long UsrCod, long CrsCod,long UsrCod,
unsigned MaxChars); unsigned MaxChars);
void Enr_UpdateUsrData (struct UsrData *UsrDat); void Enr_UpdateUsrData (struct UsrData *UsrDat);
@ -104,7 +104,7 @@ void Enr_RemAllStdsThisCrs (void);
unsigned Enr_RemAllStdsInCrs (struct Course *Crs); unsigned Enr_RemAllStdsInCrs (struct Course *Crs);
void Enr_ReqSignUpInCrs (void); void Enr_ReqSignUpInCrs (void);
void Enr_SignUpInCrs (void); void Enr_SignUpInCrs (void);
void Enr_GetNotifEnrollmentRequest (char *SummaryStr,char **ContentStr, void Enr_GetNotifEnrollmentRequest (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],char **ContentStr,
long ReqCod,unsigned MaxChars,bool GetContent); long ReqCod,unsigned MaxChars,bool GetContent);
void Enr_AskIfRejectSignUp (void); void Enr_AskIfRejectSignUp (void);
void Enr_RejectSignUp (void); void Enr_RejectSignUp (void);

View File

@ -126,7 +126,11 @@ static long Exa_GetParamsExamAnnouncement (void)
Par_GetParToText ("CrsName",Gbl.ExamAnnouncements.ExaDat.CrsFullName,Cns_MAX_BYTES_STRING); Par_GetParToText ("CrsName",Gbl.ExamAnnouncements.ExaDat.CrsFullName,Cns_MAX_BYTES_STRING);
// If the parameter is not present or is empty, initialize the string to the full name of the current course // If the parameter is not present or is empty, initialize the string to the full name of the current course
if (!Gbl.ExamAnnouncements.ExaDat.CrsFullName[0]) if (!Gbl.ExamAnnouncements.ExaDat.CrsFullName[0])
strcpy (Gbl.ExamAnnouncements.ExaDat.CrsFullName,Gbl.CurrentCrs.Crs.FullName); {
strncpy (Gbl.ExamAnnouncements.ExaDat.CrsFullName,Gbl.CurrentCrs.Crs.FullName,
Crs_MAX_LENGTH_COURSE_FULL_NAME);
Gbl.ExamAnnouncements.ExaDat.CrsFullName[Crs_MAX_LENGTH_COURSE_FULL_NAME] = '\0';
}
/***** Get the year *****/ /***** Get the year *****/
Par_GetParToText ("Year",UnsignedStr,10); Par_GetParToText ("Year",UnsignedStr,10);
@ -937,14 +941,17 @@ static void Exa_GetDataExamAnnouncementFromDB (void)
Gbl.ExamAnnouncements.ExaDat.Status = (Exa_ExamAnnouncementStatus_t) UnsignedNum; Gbl.ExamAnnouncements.ExaDat.Status = (Exa_ExamAnnouncementStatus_t) UnsignedNum;
/* Name of the course (row[2]) */ /* Name of the course (row[2]) */
strcpy (Gbl.ExamAnnouncements.ExaDat.CrsFullName,row[2]); strncpy (Gbl.ExamAnnouncements.ExaDat.CrsFullName,row[2],
Crs_MAX_LENGTH_COURSE_FULL_NAME);
Gbl.ExamAnnouncements.ExaDat.CrsFullName[Crs_MAX_LENGTH_COURSE_FULL_NAME] = '\0';
/* Year (row[3]) */ /* Year (row[3]) */
if (sscanf (row[3],"%u",&Gbl.ExamAnnouncements.ExaDat.Year) != 1) if (sscanf (row[3],"%u",&Gbl.ExamAnnouncements.ExaDat.Year) != 1)
Lay_ShowErrorAndExit ("Wrong year."); Lay_ShowErrorAndExit ("Wrong year.");
/* Exam session (row[4]) */ /* Exam session (row[4]) */
strcpy (Gbl.ExamAnnouncements.ExaDat.Session,row[4]); strncpy (Gbl.ExamAnnouncements.ExaDat.Session,row[4],Cns_MAX_BYTES_STRING);
Gbl.ExamAnnouncements.ExaDat.Session[Cns_MAX_BYTES_STRING] = '\0';
/* 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",

View File

@ -8,7 +8,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as
@ -30,6 +30,7 @@
#include <stdbool.h> // For boolean type #include <stdbool.h> // For boolean type
#include "swad_constant.h" #include "swad_constant.h"
#include "swad_course.h"
#include "swad_date.h" #include "swad_date.h"
/*****************************************************************************/ /*****************************************************************************/
@ -57,9 +58,9 @@ struct ExamData
long ExaCod; long ExaCod;
long CrsCod; long CrsCod;
Exa_ExamAnnouncementStatus_t Status; Exa_ExamAnnouncementStatus_t Status;
char CrsFullName[Cns_MAX_BYTES_STRING+1]; char CrsFullName[Crs_MAX_LENGTH_COURSE_FULL_NAME + 1];
unsigned Year; // Number of year (0 (N.A.), 1, 2, 3, 4, 5, 6) in the degree unsigned Year; // Number of year (0 (N.A.), 1, 2, 3, 4, 5, 6) in the degree
char Session[Cns_MAX_BYTES_STRING+1]; // Exam session is june, september, etc. char Session[Cns_MAX_BYTES_STRING + 1]; // Exam session is june, september, etc.
struct Date CallDate; struct Date CallDate;
struct Date ExamDate; struct Date ExamDate;
struct Hour StartTime; struct Hour StartTime;

View File

@ -6,7 +6,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as

View File

@ -8,7 +8,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as

View File

@ -6,7 +6,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as
@ -1485,19 +1485,28 @@ static void Brw_GetAndUpdateDateLastAccFileBrowser (void);
static long Brw_GetGrpLastAccZone (const char *FieldNameDB); static long Brw_GetGrpLastAccZone (const char *FieldNameDB);
static void Brw_ResetFileBrowserSize (void); static void Brw_ResetFileBrowserSize (void);
static void Brw_CalcSizeOfDirRecursive (unsigned Level,char *Path); static void Brw_CalcSizeOfDirRecursive (unsigned Level,char *Path);
static void Brw_ListDir (unsigned Level,const char *Path,const char *PathInTree); static void Brw_ListDir (unsigned Level,
const char Path[PATH_MAX + 1],
const char PathInTree[PATH_MAX + 1]);
static bool Brw_WriteRowFileBrowser (unsigned Level,Brw_ExpandTree_t ExpandTree, static bool Brw_WriteRowFileBrowser (unsigned Level,Brw_ExpandTree_t ExpandTree,
const char *PathInTree,const char *FileName); const char PathInTree[PATH_MAX + 1],
const char *FileName);
static void Brw_PutIconsRemoveCopyPaste (unsigned Level, static void Brw_PutIconsRemoveCopyPaste (unsigned Level,
const char *PathInTree,const char *FileName,const char *FileNameToShow); const char PathInTree[PATH_MAX + 1],
const char *FileName,const char *FileNameToShow);
static bool Brw_CheckIfCanPasteIn (unsigned Level); static bool Brw_CheckIfCanPasteIn (unsigned Level);
static void Brw_PutIconRemoveFile (const char *PathInTree,const char *FileName,const char *FileNameToShow); static void Brw_PutIconRemoveFile (const char PathInTree[PATH_MAX + 1],
static void Brw_PutIconRemoveDir (const char *PathInTree,const char *FileName,const char *FileNameToShow); const char *FileName,const char *FileNameToShow);
static void Brw_PutIconCopy (const char *PathInTree,const char *FileName,const char *FileNameShow); static void Brw_PutIconRemoveDir (const char PathInTree[PATH_MAX + 1],
static void Brw_PutIconPasteOn (const char *PathInTree,const char *FileName,const char *FileNameToShow); const char *FileName,const char *FileNameToShow);
static void Brw_PutIconCopy (const char PathInTree[PATH_MAX + 1],
const char *FileName,const char *FileNameShow);
static void Brw_PutIconPasteOn (const char PathInTree[PATH_MAX + 1],
const char *FileName,const char *FileNameToShow);
static void Brw_PutIconPasteOff (void); static void Brw_PutIconPasteOff (void);
static void Brw_IndentAndWriteIconExpandContract (unsigned Level,Brw_ExpandTree_t ExpandTree, static void Brw_IndentAndWriteIconExpandContract (unsigned Level,Brw_ExpandTree_t ExpandTree,
const char *PathInTree,const char *FileName,const char *FileNameToShow); const char PathInTree[PATH_MAX + 1],
const char *FileName,const char *FileNameToShow);
static void Brw_IndentDependingOnLevel (unsigned Level); static void Brw_IndentDependingOnLevel (unsigned Level);
static void Brw_PutIconShow (unsigned Level,const char *PathInTree,const char *FileName,const char *FileNameToShow); static void Brw_PutIconShow (unsigned Level,const char *PathInTree,const char *FileName,const char *FileNameToShow);
static void Brw_PutIconHide (unsigned Level,const char *PathInTree,const char *FileName,const char *FileNameToShow); static void Brw_PutIconHide (unsigned Level,const char *PathInTree,const char *FileName,const char *FileNameToShow);
@ -1529,16 +1538,16 @@ static void Brw_UpdatePathInClipboard (void);
static long Brw_GetCodForClipboard (void); static long Brw_GetCodForClipboard (void);
static long Brw_GetWorksUsrCodForClipboard (void); static long Brw_GetWorksUsrCodForClipboard (void);
static void Brw_InsFoldersInPathAndUpdOtherFoldersInExpandedFolders (const char *Path); static void Brw_InsFoldersInPathAndUpdOtherFoldersInExpandedFolders (const char Path[PATH_MAX + 1]);
static void Brw_RemThisFolderAndUpdOtherFoldersFromExpandedFolders (const char *Path); static void Brw_RemThisFolderAndUpdOtherFoldersFromExpandedFolders (const char Path[PATH_MAX + 1]);
static void Brw_InsertFolderInExpandedFolders (const char *Path); static void Brw_InsertFolderInExpandedFolders (const char Path[PATH_MAX + 1]);
static void Brw_UpdateClickTimeOfThisFileBrowserInExpandedFolders (void); static void Brw_UpdateClickTimeOfThisFileBrowserInExpandedFolders (void);
static void Brw_RemoveFolderFromExpandedFolders (const char *Path); static void Brw_RemoveFolderFromExpandedFolders (const char Path[PATH_MAX + 1]);
static void Brw_RemoveAffectedExpandedFolders (const char *Path); static void Brw_RemoveAffectedExpandedFolders (const char Path[PATH_MAX + 1]);
static void Brw_RenameAffectedExpandedFolders (Brw_FileBrowser_t FileBrowser, static void Brw_RenameAffectedExpandedFolders (Brw_FileBrowser_t FileBrowser,
long MyUsrCod,long WorksUsrCod, long MyUsrCod,long WorksUsrCod,
const char *OldPath,const char *NewPath); const char *OldPath,const char *NewPath);
static bool Brw_GetIfExpandedTree (const char *Path); static bool Brw_GetIfExpandedTree (const char Path[PATH_MAX + 1]);
static long Brw_GetCodForExpandedFolders (void); static long Brw_GetCodForExpandedFolders (void);
static long Brw_GetWorksUsrCodForExpandedFolders (void); static long Brw_GetWorksUsrCodForExpandedFolders (void);
@ -1546,10 +1555,10 @@ static void Brw_RemoveExpiredClipboards (void);
static void Brw_RemoveAffectedClipboards (Brw_FileBrowser_t FileBrowser, static void Brw_RemoveAffectedClipboards (Brw_FileBrowser_t FileBrowser,
long MyUsrCod,long WorksUsrCod); long MyUsrCod,long WorksUsrCod);
static void Brw_PasteClipboard (void); static void Brw_PasteClipboard (void);
static unsigned Brw_NumLevelsInPath (const char *Path); static unsigned Brw_NumLevelsInPath (const char Path[PATH_MAX + 1]);
static bool Brw_PasteTreeIntoFolder (unsigned Level, static bool Brw_PasteTreeIntoFolder (unsigned Level,
const char *PathOrg, const char PathOrg[PATH_MAX + 1],
const char *PathDstInTree, const char PathDstInTree[PATH_MAX + 1],
struct Brw_NumObjects *Pasted, struct Brw_NumObjects *Pasted,
long *FirstFilCod); long *FirstFilCod);
static void Brw_PutFormToCreateAFolder (const char *FileNameToShow); static void Brw_PutFormToCreateAFolder (const char *FileNameToShow);
@ -1573,19 +1582,21 @@ static void Brw_GetFileViewsFromLoggedUsrs (struct FileMetadata *FileMetadata);
static void Brw_GetFileViewsFromNonLoggedUsrs (struct FileMetadata *FileMetadata); static void Brw_GetFileViewsFromNonLoggedUsrs (struct FileMetadata *FileMetadata);
static unsigned Brw_GetFileViewsFromMe (long FilCod); static unsigned Brw_GetFileViewsFromMe (long FilCod);
static void Brw_UpdateFileViews (unsigned NumViews,long FilCod); static void Brw_UpdateFileViews (unsigned NumViews,long FilCod);
static bool Brw_GetIfFolderHasPublicFiles (const char *Path); static bool Brw_GetIfFolderHasPublicFiles (const char Path[PATH_MAX + 1]);
static void Brw_ChangeFileOrFolderHiddenInDB (const char *Path,bool IsHidden); static void Brw_ChangeFileOrFolderHiddenInDB (const char Path[PATH_MAX + 1],bool IsHidden);
static void Brw_ChangeFilePublicInDB (long PublisherUsrCod,const char *Path, static void Brw_ChangeFilePublicInDB (long PublisherUsrCod,const char *Path,
bool IsPublic,Brw_License_t License); bool IsPublic,Brw_License_t License);
static long Brw_GetZoneUsrCodForFiles (void); static long Brw_GetZoneUsrCodForFiles (void);
static void Brw_RemoveOneFileOrFolderFromDB (const char *Path); static void Brw_RemoveOneFileOrFolderFromDB (const char Path[PATH_MAX + 1]);
static void Brw_RemoveChildrenOfFolderFromDB (const char *Path); static void Brw_RemoveChildrenOfFolderFromDB (const char Path[PATH_MAX + 1]);
static void Brw_RenameOneFolderInDB (const char *OldPath,const char *NewPath); static void Brw_RenameOneFolderInDB (const char OldPath[PATH_MAX + 1],
static void Brw_RenameChildrenFilesOrFoldersInDB (const char *OldPath,const char *NewPath); const char NewPath[PATH_MAX + 1]);
static void Brw_RenameChildrenFilesOrFoldersInDB (const char OldPath[PATH_MAX + 1],
const char NewPath[PATH_MAX + 1]);
static bool Brw_CheckIfICanEditFileOrFolder (unsigned Level); static bool Brw_CheckIfICanEditFileOrFolder (unsigned Level);
static bool Brw_CheckIfICanCreateIntoFolder (unsigned Level); static bool Brw_CheckIfICanCreateIntoFolder (unsigned Level);
static bool Brw_CheckIfICanModifySharedFileOrFolder (void); static bool Brw_CheckIfICanModifySharedFileOrFolder (void);
@ -1594,15 +1605,16 @@ static void Brw_WriteRowDocData (unsigned *NumDocsNotHidden,MYSQL_ROW row);
static void Brw_PutLinkToAskRemOldFiles (void); static void Brw_PutLinkToAskRemOldFiles (void);
static void Brw_RemoveOldFilesInBrowser (unsigned Months,struct Brw_NumObjects *Removed); static void Brw_RemoveOldFilesInBrowser (unsigned Months,struct Brw_NumObjects *Removed);
static void Brw_ScanDirRemovingOldFiles (unsigned Level,const char *Path, static void Brw_ScanDirRemovingOldFiles (unsigned Level,
const char *PathInTree, const char Path[PATH_MAX + 1],
const char PathInTree[PATH_MAX + 1],
time_t TimeRemoveFilesOlder, time_t TimeRemoveFilesOlder,
struct Brw_NumObjects *Removed); struct Brw_NumObjects *Removed);
static void Brw_RemoveFileFromDiskAndDB (const char *Path, static void Brw_RemoveFileFromDiskAndDB (const char Path[PATH_MAX + 1],
const char *FullPathInTree); const char FullPathInTree[PATH_MAX + 1]);
static int Brw_RemoveFolderFromDiskAndDB (const char *Path, static int Brw_RemoveFolderFromDiskAndDB (const char Path[PATH_MAX + 1],
const char *FullPathInTree); const char FullPathInTree[PATH_MAX + 1]);
/*****************************************************************************/ /*****************************************************************************/
/***************** Get parameters related to file browser ********************/ /***************** Get parameters related to file browser ********************/
@ -2372,8 +2384,15 @@ static void Brw_GetDataCurrentGrp (void)
if (Gbl.CurrentCrs.Grps.GrpCod > 0) if (Gbl.CurrentCrs.Grps.GrpCod > 0)
{ {
Gbl.CurrentCrs.Grps.GrpTyp.GrpTypCod = GrpDat.GrpTypCod; Gbl.CurrentCrs.Grps.GrpTyp.GrpTypCod = GrpDat.GrpTypCod;
strcpy (Gbl.CurrentCrs.Grps.GrpTyp.GrpTypName , GrpDat.GrpTypName);
strcpy (Gbl.CurrentCrs.Grps.GrpName , GrpDat.GrpName); strncpy (Gbl.CurrentCrs.Grps.GrpTyp.GrpTypName,GrpDat.GrpTypName,
Grp_MAX_LENGTH_GROUP_TYPE_NAME);
Gbl.CurrentCrs.Grps.GrpTyp.GrpTypName[Grp_MAX_LENGTH_GROUP_TYPE_NAME] = '\0';
strncpy (Gbl.CurrentCrs.Grps.GrpName,GrpDat.GrpName,
Grp_MAX_LENGTH_GROUP_NAME);
Gbl.CurrentCrs.Grps.GrpName[Grp_MAX_LENGTH_GROUP_NAME] = '\0';
Gbl.CurrentCrs.Grps.MaxStudents = GrpDat.MaxStudents; Gbl.CurrentCrs.Grps.MaxStudents = GrpDat.MaxStudents;
Gbl.CurrentCrs.Grps.Open = GrpDat.Open; Gbl.CurrentCrs.Grps.Open = GrpDat.Open;
Gbl.CurrentCrs.Grps.FileZones = GrpDat.FileZones; Gbl.CurrentCrs.Grps.FileZones = GrpDat.FileZones;
@ -2593,8 +2612,9 @@ static void Brw_SetPathFileBrowser (void)
case Brw_ADMI_SHARE_CRS: case Brw_ADMI_SHARE_CRS:
case Brw_SHOW_MARKS_CRS: case Brw_SHOW_MARKS_CRS:
case Brw_ADMI_MARKS_CRS: case Brw_ADMI_MARKS_CRS:
strcpy (Gbl.FileBrowser.Priv.PathAboveRootFolder, strncpy (Gbl.FileBrowser.Priv.PathAboveRootFolder,
Gbl.CurrentCrs.PathPriv); Gbl.CurrentCrs.PathPriv,PATH_MAX);
Gbl.FileBrowser.Priv.PathAboveRootFolder[PATH_MAX] = '\0';
break; break;
case Brw_SHOW_DOCUM_GRP: case Brw_SHOW_DOCUM_GRP:
case Brw_ADMI_DOCUM_GRP: case Brw_ADMI_DOCUM_GRP:
@ -2644,8 +2664,9 @@ static void Brw_SetPathFileBrowser (void)
} }
break; break;
case Brw_ADMI_BRIEF_USR: case Brw_ADMI_BRIEF_USR:
strcpy (Gbl.FileBrowser.Priv.PathAboveRootFolder, strncpy (Gbl.FileBrowser.Priv.PathAboveRootFolder,
Gbl.Usrs.Me.PathDir); Gbl.Usrs.Me.PathDir,PATH_MAX);
Gbl.FileBrowser.Priv.PathAboveRootFolder[PATH_MAX] = '\0';
break; break;
default: default:
return; return;
@ -4786,7 +4807,10 @@ 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
strcpy (Gbl.FileBrowser.TmpPubDir,Gbl.UniqueNameEncrypted); {
strncpy (Gbl.FileBrowser.TmpPubDir,Gbl.UniqueNameEncrypted,NAME_MAX);
Gbl.FileBrowser.TmpPubDir[NAME_MAX] = '\0';
}
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.");
@ -5009,7 +5033,9 @@ static void Brw_CalcSizeOfDirRecursive (unsigned Level,char *Path)
/************************ List a directory recursively ***********************/ /************************ List a directory recursively ***********************/
/*****************************************************************************/ /*****************************************************************************/
static void Brw_ListDir (unsigned Level,const char *Path,const char *PathInTree) static void Brw_ListDir (unsigned Level,
const char Path[PATH_MAX + 1],
const char PathInTree[PATH_MAX + 1])
{ {
struct dirent **FileList; struct dirent **FileList;
struct dirent **SubdirFileList; struct dirent **SubdirFileList;
@ -5098,7 +5124,8 @@ static void Brw_ListDir (unsigned Level,const char *Path,const char *PathInTree)
// If the row is visible, return true. If it is hidden, return false // If the row is visible, return true. If it is hidden, return false
static bool Brw_WriteRowFileBrowser (unsigned Level,Brw_ExpandTree_t ExpandTree, static bool Brw_WriteRowFileBrowser (unsigned Level,Brw_ExpandTree_t ExpandTree,
const char *PathInTree,const char *FileName) const char PathInTree[PATH_MAX + 1],
const char *FileName)
{ {
bool RowSetAsHidden = false; bool RowSetAsHidden = false;
bool RowSetAsPublic = false; bool RowSetAsPublic = false;
@ -5329,8 +5356,11 @@ 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
strcpy (Gbl.FileBrowser.Priv.FullPathInTree, {
PathInTreeUntilFileOrFolder); strncpy (Gbl.FileBrowser.Priv.FullPathInTree,
PathInTreeUntilFileOrFolder,PATH_MAX);
Gbl.FileBrowser.Priv.FullPathInTree[PATH_MAX] = '\0';
}
} }
/*****************************************************************************/ /*****************************************************************************/
@ -5338,7 +5368,8 @@ void Brw_SetFullPathInTree (const char *PathInTreeUntilFileOrFolder,const char *
/*****************************************************************************/ /*****************************************************************************/
static void Brw_PutIconsRemoveCopyPaste (unsigned Level, static void Brw_PutIconsRemoveCopyPaste (unsigned Level,
const char *PathInTree,const char *FileName,const char *FileNameToShow) const char PathInTree[PATH_MAX + 1],
const char *FileName,const char *FileNameToShow)
{ {
/***** Icon to remove folder, file or link *****/ /***** Icon to remove folder, file or link *****/
switch (Gbl.FileBrowser.FileType) switch (Gbl.FileBrowser.FileType)
@ -5424,7 +5455,8 @@ static bool Brw_CheckIfCanPasteIn (unsigned Level)
/*****************************************************************************/ /*****************************************************************************/
// Gbl.FileBrowser.FileType can be Brw_IS_FILE or Brw_IS_LINK // Gbl.FileBrowser.FileType can be Brw_IS_FILE or Brw_IS_LINK
static void Brw_PutIconRemoveFile (const char *PathInTree,const char *FileName,const char *FileNameToShow) static void Brw_PutIconRemoveFile (const char PathInTree[PATH_MAX + 1],
const char *FileName,const char *FileNameToShow)
{ {
extern const char *Txt_Remove_FILE_OR_LINK_X; extern const char *Txt_Remove_FILE_OR_LINK_X;
@ -5455,7 +5487,8 @@ static void Brw_PutIconRemoveFile (const char *PathInTree,const char *FileName,c
/****************** Write link and icon to remove a folder *******************/ /****************** Write link and icon to remove a folder *******************/
/*****************************************************************************/ /*****************************************************************************/
static void Brw_PutIconRemoveDir (const char *PathInTree,const char *FileName,const char *FileNameToShow) static void Brw_PutIconRemoveDir (const char PathInTree[PATH_MAX + 1],
const char *FileName,const char *FileNameToShow)
{ {
extern const char *Txt_Remove_folder_X; extern const char *Txt_Remove_folder_X;
@ -5486,7 +5519,8 @@ static void Brw_PutIconRemoveDir (const char *PathInTree,const char *FileName,co
/************** Write link e icon to copy a file o a folder ******************/ /************** Write link e icon to copy a file o a folder ******************/
/*****************************************************************************/ /*****************************************************************************/
static void Brw_PutIconCopy (const char *PathInTree,const char *FileName,const char *FileNameToShow) static void Brw_PutIconCopy (const char PathInTree[PATH_MAX + 1],
const char *FileName,const char *FileNameToShow)
{ {
extern const char *Txt_Copy_FOLDER_FILE_OR_LINK_X; extern const char *Txt_Copy_FOLDER_FILE_OR_LINK_X;
@ -5513,7 +5547,8 @@ static void Brw_PutIconCopy (const char *PathInTree,const char *FileName,const c
/************** Write link e icon to paste a file or a folder ****************/ /************** Write link e icon to paste a file or a folder ****************/
/*****************************************************************************/ /*****************************************************************************/
static void Brw_PutIconPasteOn (const char *PathInTree,const char *FileName,const char *FileNameToShow) static void Brw_PutIconPasteOn (const char PathInTree[PATH_MAX + 1],
const char *FileName,const char *FileNameToShow)
{ {
extern const char *Txt_Paste_in_X; extern const char *Txt_Paste_in_X;
@ -5558,7 +5593,8 @@ static void Brw_PutIconPasteOff (void)
/*****************************************************************************/ /*****************************************************************************/
static void Brw_IndentAndWriteIconExpandContract (unsigned Level,Brw_ExpandTree_t ExpandTree, static void Brw_IndentAndWriteIconExpandContract (unsigned Level,Brw_ExpandTree_t ExpandTree,
const char *PathInTree,const char *FileName,const char *FileNameToShow) const char PathInTree[PATH_MAX + 1],
const char *FileName,const char *FileNameToShow)
{ {
extern const char *Txt_Expand; extern const char *Txt_Expand;
extern const char *Txt_Contract; extern const char *Txt_Contract;
@ -6688,7 +6724,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]) */
strcpy (Gbl.FileBrowser.Clipboard.Path,row[4]); strncpy (Gbl.FileBrowser.Clipboard.Path,row[4],PATH_MAX);
Gbl.FileBrowser.Clipboard.Path[PATH_MAX] = '\0';
Str_SplitFullPathIntoPathAndFileName (Gbl.FileBrowser.Clipboard.Path, Str_SplitFullPathIntoPathAndFileName (Gbl.FileBrowser.Clipboard.Path,
PathUntilFileName, PathUntilFileName,
Gbl.FileBrowser.Clipboard.FileName); Gbl.FileBrowser.Clipboard.FileName);
@ -6868,10 +6905,10 @@ static long Brw_GetWorksUsrCodForClipboard (void)
/*****************************************************************************/ /*****************************************************************************/
// Important: parameter Path must end in a folder, not in a file // Important: parameter Path must end in a folder, not in a file
static void Brw_InsFoldersInPathAndUpdOtherFoldersInExpandedFolders (const char *Path) static void Brw_InsFoldersInPathAndUpdOtherFoldersInExpandedFolders (const char Path[PATH_MAX + 1])
{ {
char *Ptr; char *Ptr;
char CopyOfPath[PATH_MAX+1]; char CopyOfPath[PATH_MAX + 1];
/* Example: /* Example:
Path = root_folder/folder1/folder2/folder3 Path = root_folder/folder1/folder2/folder3
1. Try to insert CopyOfPath = "root_folder/folder1/folder2/folder3" 1. Try to insert CopyOfPath = "root_folder/folder1/folder2/folder3"
@ -6883,7 +6920,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 *****/
strcpy (CopyOfPath,Path); strncpy (CopyOfPath,Path,PATH_MAX);
CopyOfPath[PATH_MAX] = '\0';
/***** 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
@ -6907,7 +6945,7 @@ static void Brw_InsFoldersInPathAndUpdOtherFoldersInExpandedFolders (const char
/******* and update click time of the other folders in the expl. tree ********/ /******* and update click time of the other folders in the expl. tree ********/
/*****************************************************************************/ /*****************************************************************************/
static void Brw_RemThisFolderAndUpdOtherFoldersFromExpandedFolders (const char *Path) static void Brw_RemThisFolderAndUpdOtherFoldersFromExpandedFolders (const char Path[PATH_MAX + 1])
{ {
/***** Remove Path from expanded folders table *****/ /***** Remove Path from expanded folders table *****/
Brw_RemoveFolderFromExpandedFolders (Path); Brw_RemoveFolderFromExpandedFolders (Path);
@ -6920,7 +6958,7 @@ static void Brw_RemThisFolderAndUpdOtherFoldersFromExpandedFolders (const char *
/************************* Insert path in expanded folders *******************/ /************************* Insert path in expanded folders *******************/
/*****************************************************************************/ /*****************************************************************************/
static void Brw_InsertFolderInExpandedFolders (const char *Path) static void Brw_InsertFolderInExpandedFolders (const char Path[PATH_MAX + 1])
{ {
long Cod = Brw_GetCodForExpandedFolders (); long Cod = Brw_GetCodForExpandedFolders ();
long WorksUsrCod = Brw_GetWorksUsrCodForExpandedFolders (); long WorksUsrCod = Brw_GetWorksUsrCodForExpandedFolders ();
@ -6980,7 +7018,7 @@ static void Brw_UpdateClickTimeOfThisFileBrowserInExpandedFolders (void)
/********************** Remove path from expanded folders ********************/ /********************** Remove path from expanded folders ********************/
/*****************************************************************************/ /*****************************************************************************/
static void Brw_RemoveFolderFromExpandedFolders (const char *Path) static void Brw_RemoveFolderFromExpandedFolders (const char Path[PATH_MAX + 1])
{ {
long Cod = Brw_GetCodForExpandedFolders (); long Cod = Brw_GetCodForExpandedFolders ();
long WorksUsrCod = Brw_GetWorksUsrCodForExpandedFolders (); long WorksUsrCod = Brw_GetWorksUsrCodForExpandedFolders ();
@ -7017,7 +7055,7 @@ static void Brw_RemoveFolderFromExpandedFolders (const char *Path)
/***** Remove expanded folders with paths from a course or from a user *******/ /***** Remove expanded folders with paths from a course or from a user *******/
/*****************************************************************************/ /*****************************************************************************/
static void Brw_RemoveAffectedExpandedFolders (const char *Path) static void Brw_RemoveAffectedExpandedFolders (const char Path[PATH_MAX + 1])
{ {
long Cod = Brw_GetCodForExpandedFolders (); long Cod = Brw_GetCodForExpandedFolders ();
long WorksUsrCod = Brw_GetWorksUsrCodForExpandedFolders (); long WorksUsrCod = Brw_GetWorksUsrCodForExpandedFolders ();
@ -7122,7 +7160,7 @@ static void Brw_RenameAffectedExpandedFolders (Brw_FileBrowser_t FileBrowser,
/************* Check if a folder from a file browser is expanded *************/ /************* Check if a folder from a file browser is expanded *************/
/*****************************************************************************/ /*****************************************************************************/
static bool Brw_GetIfExpandedTree (const char *Path) static bool Brw_GetIfExpandedTree (const char Path[PATH_MAX + 1])
{ {
long Cod = Brw_GetCodForExpandedFolders (); long Cod = Brw_GetCodForExpandedFolders ();
long WorksUsrCod = Brw_GetWorksUsrCodForExpandedFolders (); long WorksUsrCod = Brw_GetWorksUsrCodForExpandedFolders ();
@ -7578,7 +7616,7 @@ static void Brw_PasteClipboard (void)
/****************** Compute number of levels in a path ***********************/ /****************** Compute number of levels in a path ***********************/
/*****************************************************************************/ /*****************************************************************************/
static unsigned Brw_NumLevelsInPath (const char *Path) static unsigned Brw_NumLevelsInPath (const char Path[PATH_MAX + 1])
{ {
unsigned NumLevls = 0; unsigned NumLevls = 0;
@ -7595,8 +7633,8 @@ static unsigned Brw_NumLevelsInPath (const char *Path)
// Return true if the copy has been made successfully, and false if not // Return true if the copy has been made successfully, and false if not
static bool Brw_PasteTreeIntoFolder (unsigned LevelOrg, static bool Brw_PasteTreeIntoFolder (unsigned LevelOrg,
const char *PathOrg, const char PathOrg[PATH_MAX + 1],
const char *PathDstInTree, const char PathDstInTree[PATH_MAX + 1],
struct Brw_NumObjects *Pasted, struct Brw_NumObjects *Pasted,
long *FirstFilCod) long *FirstFilCod)
{ {
@ -7651,7 +7689,10 @@ 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
strcpy (PathDstInTreeWithFile,PathDstInTree); {
strncpy (PathDstInTreeWithFile,PathDstInTree,PATH_MAX);
PathDstInTreeWithFile[PATH_MAX] = '\0';
}
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);
@ -8532,10 +8573,18 @@ static bool Brw_RcvFileInFileBrw (Brw_UploadType_t UploadType)
} }
} }
else // Empty filename else // Empty filename
strcpy (Gbl.Message,Txt_UPLOAD_FILE_You_must_specify_the_file_NO_HTML); {
strncpy (Gbl.Message,Txt_UPLOAD_FILE_You_must_specify_the_file_NO_HTML,
Lay_MAX_BYTES_ALERT);
Gbl.Message[Lay_MAX_BYTES_ALERT] = '\0';
}
} }
else // I do not have permission to create files here else // I do not have permission to create files here
strcpy (Gbl.Message,Txt_UPLOAD_FILE_Forbidden_NO_HTML); {
strncpy (Gbl.Message,Txt_UPLOAD_FILE_Forbidden_NO_HTML,
Lay_MAX_BYTES_ALERT);
Gbl.Message[Lay_MAX_BYTES_ALERT] = '\0';
}
return UploadSucessful; return UploadSucessful;
} }
@ -10425,7 +10474,7 @@ static void Brw_UpdateFileViews (unsigned NumViews,long FilCod)
/*********** Check if a folder contains file(s) marked as public *************/ /*********** Check if a folder contains file(s) marked as public *************/
/*****************************************************************************/ /*****************************************************************************/
static bool Brw_GetIfFolderHasPublicFiles (const char *Path) static bool Brw_GetIfFolderHasPublicFiles (const char Path[PATH_MAX + 1])
{ {
long Cod = Brw_GetCodForFiles (); long Cod = Brw_GetCodForFiles ();
long ZoneUsrCod = Brw_GetZoneUsrCodForFiles (); long ZoneUsrCod = Brw_GetZoneUsrCodForFiles ();
@ -10480,7 +10529,7 @@ unsigned Brw_GetNumPublicFilesUsr (long UsrCod)
/***************** Change hiddeness of file in the database ******************/ /***************** Change hiddeness of file in the database ******************/
/*****************************************************************************/ /*****************************************************************************/
static void Brw_ChangeFileOrFolderHiddenInDB (const char *Path,bool IsHidden) static void Brw_ChangeFileOrFolderHiddenInDB (const char Path[PATH_MAX + 1],bool IsHidden)
{ {
long Cod = Brw_GetCodForFiles (); long Cod = Brw_GetCodForFiles ();
long ZoneUsrCod = Brw_GetZoneUsrCodForFiles (); long ZoneUsrCod = Brw_GetZoneUsrCodForFiles ();
@ -10690,7 +10739,7 @@ long Brw_AddPathToDB (long PublisherUsrCod,Brw_FileType_t FileType,
/**************** Remove a file or folder from the database ******************/ /**************** Remove a file or folder from the database ******************/
/*****************************************************************************/ /*****************************************************************************/
static void Brw_RemoveOneFileOrFolderFromDB (const char *Path) static void Brw_RemoveOneFileOrFolderFromDB (const char Path[PATH_MAX + 1])
{ {
long Cod = Brw_GetCodForFiles (); long Cod = Brw_GetCodForFiles ();
long ZoneUsrCod = Brw_GetZoneUsrCodForFiles (); long ZoneUsrCod = Brw_GetZoneUsrCodForFiles ();
@ -10735,7 +10784,7 @@ static void Brw_RemoveOneFileOrFolderFromDB (const char *Path)
/************** Remove children of a folder from the database ****************/ /************** Remove children of a folder from the database ****************/
/*****************************************************************************/ /*****************************************************************************/
static void Brw_RemoveChildrenOfFolderFromDB (const char *Path) static void Brw_RemoveChildrenOfFolderFromDB (const char Path[PATH_MAX + 1])
{ {
long Cod = Brw_GetCodForFiles (); long Cod = Brw_GetCodForFiles ();
long ZoneUsrCod = Brw_GetZoneUsrCodForFiles (); long ZoneUsrCod = Brw_GetZoneUsrCodForFiles ();
@ -10780,7 +10829,8 @@ static void Brw_RemoveChildrenOfFolderFromDB (const char *Path)
/*************** Rename a file or folder in table of files *******************/ /*************** Rename a file or folder in table of files *******************/
/*****************************************************************************/ /*****************************************************************************/
static void Brw_RenameOneFolderInDB (const char *OldPath,const char *NewPath) static void Brw_RenameOneFolderInDB (const char OldPath[PATH_MAX + 1],
const char NewPath[PATH_MAX + 1])
{ {
long Cod = Brw_GetCodForFiles (); long Cod = Brw_GetCodForFiles ();
long ZoneUsrCod = Brw_GetZoneUsrCodForFiles (); long ZoneUsrCod = Brw_GetZoneUsrCodForFiles ();
@ -10800,7 +10850,8 @@ static void Brw_RenameOneFolderInDB (const char *OldPath,const char *NewPath)
/************** Rename children of a folder in table of files ****************/ /************** Rename children of a folder in table of files ****************/
/*****************************************************************************/ /*****************************************************************************/
static void Brw_RenameChildrenFilesOrFoldersInDB (const char *OldPath,const char *NewPath) static void Brw_RenameChildrenFilesOrFoldersInDB (const char OldPath[PATH_MAX + 1],
const char NewPath[PATH_MAX + 1])
{ {
long Cod = Brw_GetCodForFiles (); long Cod = Brw_GetCodForFiles ();
long ZoneUsrCod = Brw_GetZoneUsrCodForFiles (); long ZoneUsrCod = Brw_GetZoneUsrCodForFiles ();
@ -11115,9 +11166,9 @@ void Brw_RemoveUsrWorksInAllCrss (struct UsrData *UsrDat,Cns_QuietOrVerbose_t Qu
/*****************************************************************************/ /*****************************************************************************/
// This function may be called inside a web service, so don't report error // This function may be called inside a web service, so don't report error
#define Brw_MAX_BYTES_FILE_CONTENT_STR (100+NAME_MAX + 100+PATH_MAX + 100+(Usr_MAX_BYTES_NAME+1)*3 + 100+Fil_MAX_BYTES_FILE_SIZE_STRING) #define Brw_MAX_BYTES_FILE_CONTENT_STR (100 + NAME_MAX + 100 + PATH_MAX + 100+(Usr_MAX_BYTES_NAME + 1) * 3 + 100 + Fil_MAX_BYTES_FILE_SIZE_STRING)
void Brw_GetSummaryAndContentOfFile (char *SummaryStr,char **ContentStr, void Brw_GetSummaryAndContentOfFile (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],char **ContentStr,
long FilCod,unsigned MaxChars,bool GetContent) long FilCod,unsigned MaxChars,bool GetContent)
{ {
extern const char *Txt_Filename; extern const char *Txt_Filename;
@ -11138,7 +11189,8 @@ void Brw_GetSummaryAndContentOfFile (char *SummaryStr,char **ContentStr,
Brw_GetFileMetadataByCod (&FileMetadata); Brw_GetFileMetadataByCod (&FileMetadata);
/***** Copy file name into summary string *****/ /***** Copy file name into summary string *****/
strcpy (SummaryStr,FileMetadata.FilFolLnkName); strncpy (SummaryStr,FileMetadata.FilFolLnkName,Cns_MAX_BYTES_TEXT);
SummaryStr[Cns_MAX_BYTES_TEXT] = '\0';
if (MaxChars) if (MaxChars)
Str_LimitLengthHTMLStr (SummaryStr,MaxChars); Str_LimitLengthHTMLStr (SummaryStr,MaxChars);
@ -11669,8 +11721,9 @@ static void Brw_RemoveOldFilesInBrowser (unsigned Months,struct Brw_NumObjects *
/************* Scan a directory recursively removing old files ***************/ /************* Scan a directory recursively removing old files ***************/
/*****************************************************************************/ /*****************************************************************************/
static void Brw_ScanDirRemovingOldFiles (unsigned Level,const char *Path, static void Brw_ScanDirRemovingOldFiles (unsigned Level,
const char *PathInTree, const char Path[PATH_MAX + 1],
const char PathInTree[PATH_MAX + 1],
time_t TimeRemoveFilesOlder, time_t TimeRemoveFilesOlder,
struct Brw_NumObjects *Removed) struct Brw_NumObjects *Removed)
{ {
@ -11767,8 +11820,8 @@ static void Brw_ScanDirRemovingOldFiles (unsigned Level,const char *Path,
/******************* Remove file/link from disk and database *****************/ /******************* Remove file/link from disk and database *****************/
/*****************************************************************************/ /*****************************************************************************/
static void Brw_RemoveFileFromDiskAndDB (const char *Path, static void Brw_RemoveFileFromDiskAndDB (const char Path[PATH_MAX + 1],
const char *FullPathInTree) const char FullPathInTree[PATH_MAX + 1])
{ {
/***** Remove file from disk *****/ /***** Remove file from disk *****/
if (unlink (Path)) if (unlink (Path))
@ -11785,8 +11838,8 @@ static void Brw_RemoveFileFromDiskAndDB (const char *Path,
/*****************************************************************************/ /*****************************************************************************/
// Return the returned value of rmdir // Return the returned value of rmdir
static int Brw_RemoveFolderFromDiskAndDB (const char *Path, static int Brw_RemoveFolderFromDiskAndDB (const char Path[PATH_MAX + 1],
const char *FullPathInTree) const char FullPathInTree[PATH_MAX + 1])
{ {
int Result; int Result;

View File

@ -8,7 +8,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as
@ -245,7 +245,7 @@ void Brw_RemoveGrpZones (long CrsCod,long GrpCod);
void Brw_RemoveUsrWorksInCrs (struct UsrData *UsrDat,struct Course *Crs,Cns_QuietOrVerbose_t QuietOrVerbose); void Brw_RemoveUsrWorksInCrs (struct UsrData *UsrDat,struct Course *Crs,Cns_QuietOrVerbose_t QuietOrVerbose);
void Brw_RemoveUsrWorksInAllCrss (struct UsrData *UsrDat,Cns_QuietOrVerbose_t QuietOrVerbose); void Brw_RemoveUsrWorksInAllCrss (struct UsrData *UsrDat,Cns_QuietOrVerbose_t QuietOrVerbose);
void Brw_GetSummaryAndContentOfFile (char *SummaryStr,char **ContentStr, void Brw_GetSummaryAndContentOfFile (char SummaryStr[Cns_MAX_BYTES_TEXT + 1],char **ContentStr,
long FilCod,unsigned MaxChars,bool GetContent); long FilCod,unsigned MaxChars,bool GetContent);
unsigned Brw_ListDocsFound (const char *Query, unsigned Brw_ListDocsFound (const char *Query,

View File

@ -6,7 +6,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General 3 License as it under the terms of the GNU Affero General 3 License as

View File

@ -8,7 +8,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as

View File

@ -6,7 +6,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as

View File

@ -8,7 +8,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as

View File

@ -6,7 +6,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as

View File

@ -8,7 +8,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as
@ -178,8 +178,8 @@ struct Globals
time_t StartExecutionTimeUTC; time_t StartExecutionTimeUTC;
struct DateTime Now; struct DateTime Now;
struct Date Yesterday; struct Date Yesterday;
char Message[Lay_MAX_BYTES_ALERT]; // String for alerts char Message[Lay_MAX_BYTES_ALERT + 1]; // String for alerts
char Title[Lay_MAX_BYTES_TITLE]; // String for the help message in a link char Title[Lay_MAX_BYTES_TITLE + 1]; // String for the help message in a link
unsigned RowEvenOdd; // To alternate row colors in listings unsigned RowEvenOdd; // To alternate row colors in listings
char *ColorRows[2]; char *ColorRows[2];
const char *XMLPtr; const char *XMLPtr;
@ -453,7 +453,7 @@ struct Globals
struct GroupTypes GrpTypes; struct GroupTypes GrpTypes;
struct GroupType GrpTyp; struct GroupType GrpTyp;
long GrpCod; long GrpCod;
char GrpName[MAX_LENGTH_GROUP_NAME+1]; char GrpName[Grp_MAX_LENGTH_GROUP_NAME + 1];
int MaxStudents; int MaxStudents;
bool Open; bool Open;
bool FileZones; bool FileZones;
@ -513,13 +513,13 @@ struct Globals
} Size; } Size;
struct struct
{ {
char PathAboveRootFolder[PATH_MAX+1]; char PathAboveRootFolder[PATH_MAX + 1];
char PathRootFolder[PATH_MAX+1]; char PathRootFolder[PATH_MAX + 1];
char PathInTreeUntilFilFolLnk[PATH_MAX+1]; char PathInTreeUntilFilFolLnk[PATH_MAX + 1];
char FullPathInTree[PATH_MAX+1]; char FullPathInTree[PATH_MAX + 1];
} Priv; } Priv;
char NewFilFolLnkName[NAME_MAX+1]; char NewFilFolLnkName[NAME_MAX + 1];
char FilFolLnkName[NAME_MAX+1]; char FilFolLnkName[NAME_MAX + 1];
Brw_FileType_t FileType; Brw_FileType_t FileType;
unsigned Level; unsigned Level;
bool ICanEditFileOrFolder; // Can I modify (remove, rename, create inside, etc.) a file or folder? bool ICanEditFileOrFolder; // Can I modify (remove, rename, create inside, etc.) a file or folder?
@ -529,22 +529,22 @@ struct Globals
Brw_FileBrowser_t FileBrowser; // Type of the file browser Brw_FileBrowser_t FileBrowser; // Type of the file browser
long Cod; // Code of the institution/centre/degree/course/group related to the file browser with the clipboard long Cod; // Code of the institution/centre/degree/course/group related to the file browser with the clipboard
long WorksUsrCod; // User code of the user related to the works file browser with the clipboard long WorksUsrCod; // User code of the user related to the works file browser with the clipboard
char Path[PATH_MAX+1]; // Complete path in the file browser char Path[PATH_MAX + 1]; // Complete path in the file browser
char FileName[NAME_MAX+1]; // File name, last part of complete path in the file browser char FileName[NAME_MAX + 1]; // File name, last part of complete path in the file browser
unsigned Level; unsigned Level;
Brw_FileType_t FileType; // Folder, file or link Brw_FileType_t FileType; // Folder, file or link
bool IsThisTree; // When showing a file browser, is it that corresponding to the clipboard? bool IsThisTree; // When showing a file browser, is it that corresponding to the clipboard?
bool IsThisFile; // When showing a row of a file browser, are we in the path of the clipboard? bool IsThisFile; // When showing a row of a file browser, are we in the path of the clipboard?
} Clipboard; } Clipboard;
char TmpPubDir[NAME_MAX+1]; char TmpPubDir[NAME_MAX + 1];
bool HiddenLevels[1+Brw_MAX_DIR_LEVELS]; bool HiddenLevels[1 + Brw_MAX_DIR_LEVELS];
const char *TxtStyle; const char *TxtStyle;
const char *InputStyle; const char *InputStyle;
struct Assignment Asg; // Data of assignment when browsing level 1 or an assignment zone struct Assignment Asg; // Data of assignment when browsing level 1 or an assignment zone
struct struct
{ {
bool CreateZIP; bool CreateZIP;
char TmpDir[NAME_MAX+1]; char TmpDir[NAME_MAX + 1];
} ZIP; } ZIP;
} FileBrowser; // Struct used for a file browser } FileBrowser; // Struct used for a file browser
struct struct
@ -576,7 +576,7 @@ struct Globals
struct Course Crs; struct Course Crs;
int Level; int Level;
For_ForumOrderType_t SelectedOrderType; For_ForumOrderType_t SelectedOrderType;
char PathRelOld[PATH_MAX+1]; char PathRelOld[PATH_MAX + 1];
long ThreadToMove; long ThreadToMove;
} Forum; } Forum;
struct struct
@ -588,17 +588,17 @@ struct Globals
Msg_TypeOfMessages_t TypeOfMessages; Msg_TypeOfMessages_t TypeOfMessages;
unsigned NumMsgs; unsigned NumMsgs;
int MsgId; int MsgId;
char Subject[Cns_MAX_BYTES_SUBJECT+1]; char Subject[Cns_MAX_BYTES_SUBJECT + 1];
unsigned NumCourses; unsigned NumCourses;
struct struct
{ {
long CrsCod; long CrsCod;
char ShrtName[Crs_MAX_LENGTH_COURSE_SHRT_NAME+1]; char ShrtName[Crs_MAX_LENGTH_COURSE_SHRT_NAME + 1];
} Courses[Crs_MAX_COURSES_PER_USR]; // Distinct courses in my messages sent or received } Courses[Crs_MAX_COURSES_PER_USR]; // Distinct courses in my messages sent or received
long FilterCrsCod; // Show only messages sent from this course code long FilterCrsCod; // Show only messages sent from this course code
char FilterCrsShrtName[Crs_MAX_LENGTH_COURSE_SHRT_NAME+1]; char FilterCrsShrtName[Crs_MAX_LENGTH_COURSE_SHRT_NAME + 1];
char FilterFromTo[Usr_MAX_LENGTH_USR_NAME_OR_SURNAME*3+1]; // Show only messages from/to these users char FilterFromTo[Usr_MAX_LENGTH_USR_NAME_OR_SURNAME*3 + 1]; // Show only messages from/to these users
char FilterContent[Msg_MAX_LENGTH_FILTER_CONTENT+1]; // Show only messages that match this content char FilterContent[Msg_MAX_LENGTH_FILTER_CONTENT + 1]; // Show only messages that match this content
bool ShowOnlyUnreadMsgs; // Show only unread messages (this option is applicable only for received messages) bool ShowOnlyUnreadMsgs; // Show only unread messages (this option is applicable only for received messages)
long ExpandedMsgCod; // The current expanded message code long ExpandedMsgCod; // The current expanded message code
struct struct
@ -607,7 +607,7 @@ struct Globals
long OriginalMsgCod; // Original message code when I am editing a reply long OriginalMsgCod; // Original message code when I am editing a reply
} Reply; } Reply;
bool ShowOnlyOneRecipient; // Shown only a selected recipient or also other potential recipients? bool ShowOnlyOneRecipient; // Shown only a selected recipient or also other potential recipients?
char FileNameMail[PATH_MAX+1]; char FileNameMail[PATH_MAX + 1];
FILE *FileMail; FILE *FileMail;
} Msg; } Msg;
struct struct

View File

@ -6,7 +6,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as
@ -1161,7 +1161,7 @@ static void Grp_ListGroupTypesForEdition (void)
fprintf (Gbl.F.Out,"<input type=\"text\" name=\"GrpTypName\"" fprintf (Gbl.F.Out,"<input type=\"text\" name=\"GrpTypName\""
" size=\"12\" maxlength=\"%u\" value=\"%s\"" " size=\"12\" maxlength=\"%u\" value=\"%s\""
" onchange=\"document.getElementById('%s').submit();\" />", " onchange=\"document.getElementById('%s').submit();\" />",
MAX_LENGTH_GROUP_TYPE_NAME, Grp_MAX_LENGTH_GROUP_TYPE_NAME,
Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].GrpTypName, Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumGrpTyp].GrpTypName,
Gbl.Form.Id); Gbl.Form.Id);
Act_FormEnd (); Act_FormEnd ();
@ -1405,7 +1405,7 @@ static void Grp_ListGroupsForEdition (void)
fprintf (Gbl.F.Out,"<input type=\"text\" name=\"GrpName\"" fprintf (Gbl.F.Out,"<input type=\"text\" name=\"GrpName\""
" size=\"40\" maxlength=\"%u\" value=\"%s\"" " size=\"40\" maxlength=\"%u\" value=\"%s\""
" onchange=\"document.getElementById('%s').submit();\" />", " onchange=\"document.getElementById('%s').submit();\" />",
MAX_LENGTH_GROUP_NAME,Grp->GrpName,Gbl.Form.Id); Grp_MAX_LENGTH_GROUP_NAME,Grp->GrpName,Gbl.Form.Id);
Act_FormEnd (); Act_FormEnd ();
fprintf (Gbl.F.Out,"</td>"); fprintf (Gbl.F.Out,"</td>");
@ -2121,7 +2121,7 @@ static void Grp_PutFormToCreateGroupType (void)
" size=\"12\" maxlength=\"%u\" value=\"%s\"" " size=\"12\" maxlength=\"%u\" value=\"%s\""
" required=\"required\" />" " required=\"required\" />"
"</td>", "</td>",
MAX_LENGTH_GROUP_TYPE_NAME,Gbl.CurrentCrs.Grps.GrpTyp.GrpTypName); Grp_MAX_LENGTH_GROUP_TYPE_NAME,Gbl.CurrentCrs.Grps.GrpTyp.GrpTypName);
/***** Is it mandatory to register in any groups of this type? *****/ /***** Is it mandatory to register in any groups of this type? *****/
fprintf (Gbl.F.Out,"<td class=\"CENTER_MIDDLE\">" fprintf (Gbl.F.Out,"<td class=\"CENTER_MIDDLE\">"
@ -2264,7 +2264,7 @@ static void Grp_PutFormToCreateGroup (void)
" size=\"40\" maxlength=\"%u\" value=\"%s\"" " size=\"40\" maxlength=\"%u\" value=\"%s\""
" required=\"required\" />" " required=\"required\" />"
"</td>", "</td>",
MAX_LENGTH_GROUP_NAME,Gbl.CurrentCrs.Grps.GrpName); Grp_MAX_LENGTH_GROUP_NAME,Gbl.CurrentCrs.Grps.GrpName);
/***** Maximum number of students *****/ /***** Maximum number of students *****/
fprintf (Gbl.F.Out,"<td class=\"CENTER_MIDDLE\">" fprintf (Gbl.F.Out,"<td class=\"CENTER_MIDDLE\">"
@ -2367,7 +2367,7 @@ void Grp_GetListGrpTypesInThisCrs (Grp_WhichGroupTypes_t WhichGroupTypes)
Lay_ShowErrorAndExit ("Wrong type of group."); Lay_ShowErrorAndExit ("Wrong type of group.");
/* Get group type name (row[1]) */ /* Get group type name (row[1]) */
strncpy (Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumRow].GrpTypName,row[1],MAX_LENGTH_GROUP_TYPE_NAME); strncpy (Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumRow].GrpTypName,row[1],Grp_MAX_LENGTH_GROUP_TYPE_NAME);
/* Is it mandatory to register in any groups of this type? (row[2]) */ /* Is it mandatory to register in any groups of this type? (row[2]) */
Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumRow].MandatoryEnrollment = (row[2][0] == 'Y'); Gbl.CurrentCrs.Grps.GrpTypes.LstGrpTypes[NumRow].MandatoryEnrollment = (row[2][0] == 'Y');
@ -3121,7 +3121,7 @@ void Grp_RecFormNewGrpTyp (void)
/***** Get parameters from form *****/ /***** Get parameters from form *****/
/* Get the name of group type */ /* Get the name of group type */
Par_GetParToText ("GrpTypName",Gbl.CurrentCrs.Grps.GrpTyp.GrpTypName,MAX_LENGTH_GROUP_TYPE_NAME); Par_GetParToText ("GrpTypName",Gbl.CurrentCrs.Grps.GrpTyp.GrpTypName,Grp_MAX_LENGTH_GROUP_TYPE_NAME);
/* Get whether it is mandatory to regisrer in any group of this type */ /* Get whether it is mandatory to regisrer in any group of this type */
Par_GetParToText ("MandatoryEnrollment",YN,1); Par_GetParToText ("MandatoryEnrollment",YN,1);
@ -3185,7 +3185,7 @@ void Grp_RecFormNewGrp (void)
if ((Gbl.CurrentCrs.Grps.GrpTyp.GrpTypCod = Grp_GetParamGrpTypCod ()) > 0) // Group type valid if ((Gbl.CurrentCrs.Grps.GrpTyp.GrpTypCod = Grp_GetParamGrpTypCod ()) > 0) // Group type valid
{ {
/* Get group name */ /* Get group name */
Par_GetParToText ("GrpName",Gbl.CurrentCrs.Grps.GrpName,MAX_LENGTH_GROUP_NAME); Par_GetParToText ("GrpName",Gbl.CurrentCrs.Grps.GrpName,Grp_MAX_LENGTH_GROUP_NAME);
/* Get maximum number of students */ /* Get maximum number of students */
Par_GetParToText ("MaxStudents",UnsignedStr,10); Par_GetParToText ("MaxStudents",UnsignedStr,10);
@ -3957,7 +3957,7 @@ void Grp_RenameGroupType (void)
extern const char *Txt_The_type_of_group_X_has_been_renamed_as_Y; extern const char *Txt_The_type_of_group_X_has_been_renamed_as_Y;
extern const char *Txt_The_name_of_the_type_of_group_X_has_not_changed; extern const char *Txt_The_name_of_the_type_of_group_X_has_not_changed;
char Query[1024]; char Query[1024];
char NewNameGrpTyp[MAX_LENGTH_GROUP_TYPE_NAME+1]; char NewNameGrpTyp[Grp_MAX_LENGTH_GROUP_TYPE_NAME+1];
/***** Get parameters from form *****/ /***** Get parameters from form *****/
/* Get the code of the group type */ /* Get the code of the group type */
@ -3965,7 +3965,7 @@ void Grp_RenameGroupType (void)
Lay_ShowErrorAndExit ("Code of type of group is missing."); Lay_ShowErrorAndExit ("Code of type of group is missing.");
/* Get the new name for the group type */ /* Get the new name for the group type */
Par_GetParToText ("GrpTypName",NewNameGrpTyp,MAX_LENGTH_GROUP_TYPE_NAME); Par_GetParToText ("GrpTypName",NewNameGrpTyp,Grp_MAX_LENGTH_GROUP_TYPE_NAME);
/***** Get from the database the old name of the group type *****/ /***** Get from the database the old name of the group type *****/
Grp_GetDataOfGroupTypeByCod (&Gbl.CurrentCrs.Grps.GrpTyp); Grp_GetDataOfGroupTypeByCod (&Gbl.CurrentCrs.Grps.GrpTyp);
@ -4030,7 +4030,7 @@ void Grp_RenameGroup (void)
extern const char *Txt_The_name_of_the_group_X_has_not_changed; extern const char *Txt_The_name_of_the_group_X_has_not_changed;
struct GroupData GrpDat; struct GroupData GrpDat;
char Query[512]; char Query[512];
char NewNameGrp[MAX_LENGTH_GROUP_NAME+1]; char NewNameGrp[Grp_MAX_LENGTH_GROUP_NAME+1];
/***** Get parameters from form *****/ /***** Get parameters from form *****/
/* Get the code of the group */ /* Get the code of the group */
@ -4038,7 +4038,7 @@ void Grp_RenameGroup (void)
Lay_ShowErrorAndExit ("Code of group is missing."); Lay_ShowErrorAndExit ("Code of group is missing.");
/* Get the new name for the group */ /* Get the new name for the group */
Par_GetParToText ("GrpName",NewNameGrp,MAX_LENGTH_GROUP_NAME); Par_GetParToText ("GrpName",NewNameGrp,Grp_MAX_LENGTH_GROUP_NAME);
/***** Get from the database the type and the old name of the group *****/ /***** Get from the database the type and the old name of the group *****/
GrpDat.GrpCod = Gbl.CurrentCrs.Grps.GrpCod; GrpDat.GrpCod = Gbl.CurrentCrs.Grps.GrpCod;

View File

@ -8,7 +8,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as
@ -34,8 +34,8 @@
/***************************** Public constants ******************************/ /***************************** Public constants ******************************/
/*****************************************************************************/ /*****************************************************************************/
#define MAX_LENGTH_GROUP_TYPE_NAME 255 #define Grp_MAX_LENGTH_GROUP_TYPE_NAME (256 - 1)
#define MAX_LENGTH_GROUP_NAME 255 #define Grp_MAX_LENGTH_GROUP_NAME (256 - 1)
#define Grp_MAX_STUDENTS_IN_A_GROUP 10000 // If max of students in a group is greater than this, it is considered infinite #define Grp_MAX_STUDENTS_IN_A_GROUP 10000 // If max of students in a group is greater than this, it is considered infinite
@ -55,8 +55,8 @@ struct GroupData
long GrpCod; long GrpCod;
long GrpTypCod; long GrpTypCod;
long CrsCod; long CrsCod;
char GrpTypName[MAX_LENGTH_GROUP_TYPE_NAME+1]; char GrpTypName[Grp_MAX_LENGTH_GROUP_TYPE_NAME+1];
char GrpName[MAX_LENGTH_GROUP_NAME+1]; char GrpName[Grp_MAX_LENGTH_GROUP_NAME+1];
unsigned MaxStudents; unsigned MaxStudents;
int Vacant; int Vacant;
bool Open; // Group is open? bool Open; // Group is open?
@ -66,7 +66,7 @@ struct GroupData
struct Group struct Group
{ {
long GrpCod; // Code of group long GrpCod; // Code of group
char GrpName[MAX_LENGTH_GROUP_NAME+1]; // Name of group char GrpName[Grp_MAX_LENGTH_GROUP_NAME+1]; // Name of group
unsigned MaxStudents; unsigned MaxStudents;
unsigned NumStudents; // Number of students in the group unsigned NumStudents; // Number of students in the group
bool Open; // Group is open? bool Open; // Group is open?
@ -76,7 +76,7 @@ struct Group
struct GroupType struct GroupType
{ {
long GrpTypCod; // Code of type of group long GrpTypCod; // Code of type of group
char GrpTypName[MAX_LENGTH_GROUP_TYPE_NAME+1]; // Name of type of group char GrpTypName[Grp_MAX_LENGTH_GROUP_TYPE_NAME + 1]; // Name of type of group
bool MandatoryEnrollment; // Enrollment is mandatory? bool MandatoryEnrollment; // Enrollment is mandatory?
bool MultipleEnrollment; // Enrollment is multiple? bool MultipleEnrollment; // Enrollment is multiple?
bool MustBeOpened; // Groups must be opened? bool MustBeOpened; // Groups must be opened?

View File

@ -6,7 +6,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General 3 License as it under the terms of the GNU Affero General 3 License as

View File

@ -8,7 +8,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as

View File

@ -6,7 +6,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as

View File

@ -8,7 +8,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as

View File

@ -6,7 +6,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as

View File

@ -8,7 +8,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as

View File

@ -6,7 +6,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as

View File

@ -8,7 +8,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as

View File

@ -6,7 +6,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General 3 License as it under the terms of the GNU Affero General 3 License as

View File

@ -8,7 +8,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as

View File

@ -6,7 +6,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as

View File

@ -8,7 +8,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as

View File

@ -6,7 +6,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as

View File

@ -8,7 +8,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as

View File

@ -6,7 +6,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as

View File

@ -8,7 +8,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as

View File

@ -6,7 +6,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as

View File

@ -8,7 +8,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as
@ -33,10 +33,10 @@
/****************************** Public constants *****************************/ /****************************** Public constants *****************************/
/*****************************************************************************/ /*****************************************************************************/
#define Lay_MAX_BYTES_ALERT (16*1024) // Max. size for alert message #define Lay_MAX_BYTES_ALERT (16*1024-1) // Max. size for alert message
// Important: the size of alert message must be enough large to store the longest message. // Important: the size of alert message must be enough large to store the longest message.
#define Lay_MAX_BYTES_TITLE 1024 // Max. size for window status message #define Lay_MAX_BYTES_TITLE (1024-1)
#define Lay_HIDE_BOTH_COLUMNS 0 // 00 #define Lay_HIDE_BOTH_COLUMNS 0 // 00
#define Lay_SHOW_RIGHT_COLUMN 1 // 01 #define Lay_SHOW_RIGHT_COLUMN 1 // 01

View File

@ -6,7 +6,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as

View File

@ -8,7 +8,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as

View File

@ -6,7 +6,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General 3 License as it under the terms of the GNU Affero General 3 License as

View File

@ -8,7 +8,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as

View File

@ -6,7 +6,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as

View File

@ -8,7 +8,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as

View File

@ -6,7 +6,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as

View File

@ -6,7 +6,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as

View File

@ -8,7 +8,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as

View File

@ -6,7 +6,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as

View File

@ -8,7 +8,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as

View File

@ -6,7 +6,7 @@
and used to support university teaching. and used to support university teaching.
This file is part of SWAD core. This file is part of SWAD core.
Copyright (C) 1999-2016 Antonio Cañas Vargas Copyright (C) 1999-2017 Antonio Cañas Vargas
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as it under the terms of the GNU Affero General Public License as
@ -707,7 +707,7 @@ void Msg_RecMsgFromUsr (void)
/***** Allocate space to store a list of recipients with the following format: /***** Allocate space to store a list of recipients with the following format:
"FirstName Surname1 Surname2; FirstName Surname1 Surname2; FirstName Surname1 Surname2" *****/ "FirstName Surname1 Surname2; FirstName Surname1 Surname2; FirstName Surname1 Surname2" *****/
if ((ListUsrsDst = (char *) malloc (((Usr_MAX_BYTES_NAME+1)*3+1)*NumRecipients)) == NULL) if ((ListUsrsDst = (char *) malloc (((Usr_MAX_BYTES_NAME + 1) * 3 + 1)*NumRecipients)) == NULL)
Lay_ShowErrorAndExit ("Not enough memory to store email addresses of recipients."); Lay_ShowErrorAndExit ("Not enough memory to store email addresses of recipients.");
ListUsrsDst[0] = '\0'; ListUsrsDst[0] = '\0';

Some files were not shown because too many files have changed in this diff Show More