Version 18.7.22

This commit is contained in:
Antonio Cañas Vargas 2018-10-21 13:02:07 +02:00
parent dcbb6699bb
commit 662aca0ef6
6 changed files with 893 additions and 762 deletions

View File

@ -355,10 +355,11 @@ En OpenSWAD:
ps2pdf source.ps destination.pdf
*/
#define Log_PLATFORM_VERSION "SWAD 18.7.21 (2018-10-21)"
#define Log_PLATFORM_VERSION "SWAD 18.7.22 (2018-10-22)"
#define CSS_FILE "swad18.4.css"
#define JS_FILE "swad17.17.1.js"
/*
Version 18.7.22: Oct 20, 2018 Some sprintf for database queries changed by asprintf. (237286 lines)
Version 18.7.21: Oct 20, 2018 Some sprintf for database queries changed by asprintf. (237157 lines)
Version 18.7.20: Oct 20, 2018 Some sprintf for database queries changed by asprintf. (237092 lines)
Version 18.7.19: Oct 20, 2018 Some sprintf for database queries changed by asprintf. (237089 lines)

View File

@ -3268,6 +3268,17 @@ void DB_QueryDELETE (const char *Query,const char *MsgError)
/**************** Make other kind of query from database *********************/
/*****************************************************************************/
void DB_Query_free (const char *Query,const char *MsgError)
{
int Result;
/***** Query database *****/
Result = mysql_query (&Gbl.mysql,Query); // Returns 0 on success
free ((void *) Query);
if (Result)
DB_ExitOnMySQLError (MsgError);
}
void DB_Query (const char *Query,const char *MsgError)
{
/***** Query database *****/

View File

@ -58,6 +58,7 @@ void DB_QueryUPDATE (const char *Query,const char *MsgError);
void DB_QueryDELETE_free (const char *Query,const char *MsgError);
void DB_QueryDELETE (const char *Query,const char *MsgError);
void DB_Query_free (const char *Query,const char *MsgError);
void DB_Query (const char *Query,const char *MsgError);
void DB_FreeMySQLResult (MYSQL_RES **mysql_res);
void DB_ExitOnMySQLError (const char *Message);

View File

@ -2615,7 +2615,7 @@ unsigned Deg_ListDegsFound (const char *Query)
struct Degree Deg;
/***** Query database *****/
if ((NumDegs = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get degrees")))
if ((NumDegs = (unsigned) DB_QuerySELECT_free (Query,&mysql_res,"can not get degrees")))
{
/***** Start box and table *****/
/* Number of degrees found */

File diff suppressed because it is too large Load Diff

View File

@ -725,7 +725,7 @@ static unsigned Sch_SearchCentresInDB (const char *RangeQuery)
static unsigned Sch_SearchDegreesInDB (const char *RangeQuery)
{
char SearchQuery[Sch_MAX_BYTES_SEARCH_QUERY + 1];
char Query[1024 + Sch_MAX_BYTES_SEARCH_QUERY * 2];
char *Query;
/***** Check scope *****/
if (Gbl.Scope.Current != Sco_SCOPE_CRS)
@ -735,7 +735,7 @@ static unsigned Sch_SearchDegreesInDB (const char *RangeQuery)
if (Sch_BuildSearchQuery (SearchQuery,"degrees.FullName",NULL,NULL))
{
/***** Query database and list degrees found *****/
sprintf (Query,"SELECT degrees.DegCod"
if (asprintf (&Query,"SELECT degrees.DegCod"
" FROM degrees,centres,institutions,countries"
" WHERE %s"
" AND degrees.CtrCod=centres.CtrCod"
@ -743,7 +743,8 @@ static unsigned Sch_SearchDegreesInDB (const char *RangeQuery)
" AND institutions.CtyCod=countries.CtyCod"
"%s"
" ORDER BY degrees.FullName,institutions.FullName",
SearchQuery,RangeQuery);
SearchQuery,RangeQuery) < 0)
Lay_NotEnoughMemoryExit ();
return Deg_ListDegsFound (Query);
}
@ -822,7 +823,7 @@ static unsigned Sch_SearchOpenDocumentsInDB (const char *RangeQuery)
extern const char *Txt_open_document;
extern const char *Txt_open_documents;
char SearchQuery[Sch_MAX_BYTES_SEARCH_QUERY + 1];
char Query[(512 + Sch_MAX_BYTES_SEARCH_QUERY) * 4];
char *Query;
/***** Check user's permission *****/
if (Sch_CheckIfIHavePermissionToSearch (Sch_SEARCH_OPEN_DOCUMENTS))
@ -831,7 +832,7 @@ static unsigned Sch_SearchOpenDocumentsInDB (const char *RangeQuery)
"_latin1 "," COLLATE latin1_general_ci"))
{
/***** Build the query *****/
sprintf (Query,"SELECT * FROM "
if (asprintf (&Query,"SELECT * FROM "
"("
"SELECT files.FilCod," // Institution
"SUBSTRING(files.Path,LOCATE('/',files.Path)) AS PathFromRoot,"
@ -912,7 +913,8 @@ static unsigned Sch_SearchOpenDocumentsInDB (const char *RangeQuery)
SearchQuery,
(unsigned) Brw_ADMI_DOC_CRS,
(unsigned) Brw_ADMI_SHR_CRS,
RangeQuery);
RangeQuery) < 0)
Lay_NotEnoughMemoryExit ();
/***** Query database and list documents found *****/
/* if (Gbl.Usrs.Me.Roles.LoggedRole == Rol_SYS_ADM)
@ -934,7 +936,7 @@ static unsigned Sch_SearchDocumentsInMyCoursesInDB (const char *RangeQuery)
extern const char *Txt_document_in_my_courses;
extern const char *Txt_documents_in_my_courses;
char SearchQuery[Sch_MAX_BYTES_SEARCH_QUERY + 1];
char Query[(1024 + Sch_MAX_BYTES_SEARCH_QUERY) * 2];
char *Query;
unsigned NumDocs;
/***** Check user's permission *****/
@ -945,11 +947,11 @@ static unsigned Sch_SearchDocumentsInMyCoursesInDB (const char *RangeQuery)
{
/***** Create temporary table with codes of files in documents and shared areas accessible by me.
It is necessary to speed up the second query *****/
sprintf (Query,"DROP TEMPORARY TABLE IF EXISTS my_files_crs,my_files_grp");
if (mysql_query (&Gbl.mysql,Query))
DB_ExitOnMySQLError ("can not remove temporary table");
if (asprintf (&Query,"DROP TEMPORARY TABLE IF EXISTS my_files_crs,my_files_grp") < 0)
Lay_NotEnoughMemoryExit ();
DB_Query_free (Query,"can not remove temporary table");
sprintf (Query,"CREATE TEMPORARY TABLE my_files_crs"
if (asprintf (&Query,"CREATE TEMPORARY TABLE my_files_crs"
" (FilCod INT NOT NULL,UNIQUE INDEX(FilCod))"
" ENGINE=MEMORY"
" SELECT files.FilCod FROM crs_usr,files"
@ -960,11 +962,11 @@ static unsigned Sch_SearchDocumentsInMyCoursesInDB (const char *RangeQuery)
(unsigned) Brw_ADMI_DOC_CRS,
(unsigned) Brw_ADMI_TCH_CRS,
(unsigned) Brw_ADMI_SHR_CRS,
(unsigned) Brw_ADMI_MRK_CRS);
if (mysql_query (&Gbl.mysql,Query))
DB_ExitOnMySQLError ("can not create temporary table");
(unsigned) Brw_ADMI_MRK_CRS) < 0)
Lay_NotEnoughMemoryExit ();
DB_Query_free (Query,"can not create temporary table");
sprintf (Query,"CREATE TEMPORARY TABLE my_files_grp"
if (asprintf (&Query,"CREATE TEMPORARY TABLE my_files_grp"
" (FilCod INT NOT NULL,UNIQUE INDEX(FilCod))"
" ENGINE=MEMORY"
" SELECT files.FilCod FROM crs_grp_usr,files"
@ -975,14 +977,14 @@ static unsigned Sch_SearchDocumentsInMyCoursesInDB (const char *RangeQuery)
(unsigned) Brw_ADMI_DOC_GRP,
(unsigned) Brw_ADMI_TCH_GRP,
(unsigned) Brw_ADMI_SHR_GRP,
(unsigned) Brw_ADMI_MRK_GRP);
(unsigned) Brw_ADMI_MRK_GRP) < 0)
Lay_NotEnoughMemoryExit ();
/* if (Gbl.Usrs.Me.Roles.LoggedRole == Rol_SYS_ADM)
Lay_ShowAlert (Lay_INFO,Query); */
if (mysql_query (&Gbl.mysql,Query))
DB_ExitOnMySQLError ("can not create temporary table");
DB_Query_free (Query,"can not create temporary table");
/***** Build the query *****/
sprintf (Query,"SELECT * FROM "
if (asprintf (&Query,"SELECT * FROM "
"("
"SELECT files.FilCod,"
"SUBSTRING(files.Path,LOCATE('/',files.Path)) AS PathFromRoot,"
@ -1033,7 +1035,8 @@ static unsigned Sch_SearchDocumentsInMyCoursesInDB (const char *RangeQuery)
(unsigned) Brw_ADMI_TCH_GRP,
(unsigned) Brw_ADMI_SHR_GRP,
(unsigned) Brw_ADMI_MRK_GRP,
RangeQuery);
RangeQuery) < 0)
Lay_NotEnoughMemoryExit ();
/***** Query database and list documents found *****/
/* if (Gbl.Usrs.Me.Roles.LoggedRole == Rol_SYS_ADM)
@ -1043,9 +1046,9 @@ static unsigned Sch_SearchDocumentsInMyCoursesInDB (const char *RangeQuery)
Txt_documents_in_my_courses);
/***** Drop temporary table *****/
sprintf (Query,"DROP TEMPORARY TABLE IF EXISTS my_files_crs,my_files_grp");
if (mysql_query (&Gbl.mysql,Query))
DB_ExitOnMySQLError ("can not remove temporary table");
if (asprintf (&Query,"DROP TEMPORARY TABLE IF EXISTS my_files_crs,my_files_grp") < 0)
Lay_NotEnoughMemoryExit ();
DB_Query_free (Query,"can not remove temporary table");
return NumDocs;
}
@ -1062,7 +1065,7 @@ static unsigned Sch_SearchMyDocumentsInDB (const char *RangeQuery)
extern const char *Txt_document_from_me;
extern const char *Txt_documents_from_me;
char SearchQuery[Sch_MAX_BYTES_SEARCH_QUERY + 1];
char Query[(512 + Sch_MAX_BYTES_SEARCH_QUERY) * 5];
char *Query;
/***** Check user's permission *****/
if (Sch_CheckIfIHavePermissionToSearch (Sch_SEARCH_MY_DOCUMENTS))
@ -1071,7 +1074,7 @@ static unsigned Sch_SearchMyDocumentsInDB (const char *RangeQuery)
"_latin1 "," COLLATE latin1_general_ci"))
{
/***** Build the query *****/
sprintf (Query,"SELECT * FROM "
if (asprintf (&Query,"SELECT * FROM "
"("
"SELECT files.FilCod," // Institution
"SUBSTRING(files.Path,LOCATE('/',files.Path)) AS PathFromRoot,"
@ -1192,7 +1195,8 @@ static unsigned Sch_SearchMyDocumentsInDB (const char *RangeQuery)
(unsigned) Brw_ADMI_MRK_GRP,
RangeQuery,
Gbl.Usrs.Me.UsrDat.UsrCod,SearchQuery,
(unsigned) Brw_ADMI_BRF_USR);
(unsigned) Brw_ADMI_BRF_USR) < 0)
Lay_NotEnoughMemoryExit ();
/***** Query database and list documents found *****/
/* if (Gbl.Usrs.Me.Roles.LoggedRole == Rol_SYS_ADM)