mirror of https://github.com/acanas/swad-core.git
Version 15.235
This commit is contained in:
parent
f104cf00de
commit
6178355d7c
|
@ -124,7 +124,6 @@
|
||||||
// TODO: Optimize slow query searching messages received
|
// TODO: Optimize slow query searching messages received
|
||||||
// TODO: FIX BUG: Searching messages received gives unordered list
|
// TODO: FIX BUG: Searching messages received gives unordered list
|
||||||
|
|
||||||
// TODO: Add file size to summary in notifications of new files.
|
|
||||||
// TODO: Put Raúl Hinojosa (iSWAD developer) in a row of marks file of EC (B,C) and publish file
|
// TODO: Put Raúl Hinojosa (iSWAD developer) in a row of marks file of EC (B,C) and publish file
|
||||||
|
|
||||||
// TODO: Modify WS function getUsers changing: userRole to indicate all users, and a new parameter filter (search string (name, @nickname, mail)) to restring number of users
|
// TODO: Modify WS function getUsers changing: userRole to indicate all users, and a new parameter filter (search string (name, @nickname, mail)) to restring number of users
|
||||||
|
@ -134,13 +133,14 @@
|
||||||
/****************************** Public constants *****************************/
|
/****************************** Public constants *****************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
#define Log_PLATFORM_VERSION "SWAD 15.234 (2016-06-29)"
|
#define Log_PLATFORM_VERSION "SWAD 15.235 (2016-06-29)"
|
||||||
#define CSS_FILE "swad15.229.css"
|
#define CSS_FILE "swad15.229.css"
|
||||||
#define JS_FILE "swad15.226.js"
|
#define JS_FILE "swad15.226.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 15.235: Jun 29, 2015 Some file metadata are written in content of notifications. (203204 lines)
|
||||||
Version 15.234: Jun 29, 2015 New web service functions getUsers and findUsers. (203169 lines)
|
Version 15.234: Jun 29, 2015 New web service functions getUsers and findUsers. (203169 lines)
|
||||||
Version 15.233.4: Jun 27, 2015 Changes in links in list of notifications. (203065 lines)
|
Version 15.233.4: Jun 27, 2015 Changes in links in list of notifications. (203065 lines)
|
||||||
Version 15.233.3: Jun 27, 2015 Fixed bug in list of admins. (203074 lines)
|
Version 15.233.3: Jun 27, 2015 Fixed bug in list of admins. (203074 lines)
|
||||||
|
|
40
swad_file.c
40
swad_file.c
|
@ -523,3 +523,43 @@ void Fil_CloseXMLFile (void)
|
||||||
Gbl.F.XML = NULL; // To indicate that it is not open
|
Gbl.F.XML = NULL; // To indicate that it is not open
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
/********** Write a quantity of bytes as bytes, KiB, MiB, GiB or TiB *********/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
#define Ki 1024.0
|
||||||
|
#define Mi 1048576.0
|
||||||
|
#define Gi 1073741824.0
|
||||||
|
#define Ti 1099511627776.0
|
||||||
|
|
||||||
|
void Fil_WriteFileSizeBrief (double SizeInBytes,
|
||||||
|
char FileSizeStr[Fil_MAX_BYTES_FILE_SIZE_STRING])
|
||||||
|
{
|
||||||
|
if (SizeInBytes < Ki)
|
||||||
|
sprintf (FileSizeStr,"%.0f B" ,SizeInBytes);
|
||||||
|
else if (SizeInBytes < Mi)
|
||||||
|
sprintf (FileSizeStr,"%.0f KiB",SizeInBytes / Ki);
|
||||||
|
else if (SizeInBytes < Gi)
|
||||||
|
sprintf (FileSizeStr,"%.0f MiB",SizeInBytes / Mi);
|
||||||
|
else if (SizeInBytes < Ti)
|
||||||
|
sprintf (FileSizeStr,"%.0f GiB",SizeInBytes / Gi);
|
||||||
|
else
|
||||||
|
sprintf (FileSizeStr,"%.0f TiB",SizeInBytes / Ti);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Fil_WriteFileSizeFull (double SizeInBytes,
|
||||||
|
char FileSizeStr[Fil_MAX_BYTES_FILE_SIZE_STRING])
|
||||||
|
{
|
||||||
|
if (SizeInBytes < Ki)
|
||||||
|
sprintf (FileSizeStr,"%.0f B" ,SizeInBytes);
|
||||||
|
else if (SizeInBytes < Mi)
|
||||||
|
sprintf (FileSizeStr,"%.1f KiB",SizeInBytes / Ki);
|
||||||
|
else if (SizeInBytes < Gi)
|
||||||
|
sprintf (FileSizeStr,"%.1f MiB",SizeInBytes / Mi);
|
||||||
|
else if (SizeInBytes < Ti)
|
||||||
|
sprintf (FileSizeStr,"%.1f GiB",SizeInBytes / Gi);
|
||||||
|
else
|
||||||
|
sprintf (FileSizeStr,"%.1f TiB",SizeInBytes / Ti);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,8 @@ struct Files
|
||||||
FILE *XML; // XML file for syllabus, for directory tree
|
FILE *XML; // XML file for syllabus, for directory tree
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define Fil_MAX_BYTES_FILE_SIZE_STRING 32
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/***************************** Public prototypes *****************************/
|
/***************************** Public prototypes *****************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -73,4 +75,9 @@ void Fil_FastCopyOfFiles (const char *PathSrc,const char *PathTgt);
|
||||||
void Fil_FastCopyOfOpenFiles (FILE *FileSrc,FILE *FileTgt);
|
void Fil_FastCopyOfOpenFiles (FILE *FileSrc,FILE *FileTgt);
|
||||||
void Fil_CloseXMLFile (void);
|
void Fil_CloseXMLFile (void);
|
||||||
|
|
||||||
|
void Fil_WriteFileSizeBrief (double SizeInBytes,
|
||||||
|
char FileSizeStr[Fil_MAX_BYTES_FILE_SIZE_STRING]);
|
||||||
|
void Fil_WriteFileSizeFull (double SizeInBytes,
|
||||||
|
char FileSizeStr[Fil_MAX_BYTES_FILE_SIZE_STRING]);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -3983,9 +3983,11 @@ static void Brw_ShowSizeOfFileTree (void)
|
||||||
extern const char *Txt_file;
|
extern const char *Txt_file;
|
||||||
extern const char *Txt_files;
|
extern const char *Txt_files;
|
||||||
extern const char *Txt_of_PART_OF_A_TOTAL;
|
extern const char *Txt_of_PART_OF_A_TOTAL;
|
||||||
|
char FileSizeStr[Fil_MAX_BYTES_FILE_SIZE_STRING];
|
||||||
|
|
||||||
|
Fil_WriteFileSizeFull ((double) Gbl.FileBrowser.Size.TotalSiz,FileSizeStr);
|
||||||
fprintf (Gbl.F.Out,"<div class=\"DAT CENTER_MIDDLE\">"
|
fprintf (Gbl.F.Out,"<div class=\"DAT CENTER_MIDDLE\">"
|
||||||
"%u %s; %lu %s; %lu %s; ",
|
"%u %s; %lu %s; %lu %s; %s",
|
||||||
Gbl.FileBrowser.Size.NumLevls,
|
Gbl.FileBrowser.Size.NumLevls,
|
||||||
Gbl.FileBrowser.Size.NumLevls == 1 ? Txt_level :
|
Gbl.FileBrowser.Size.NumLevls == 1 ? Txt_level :
|
||||||
Txt_levels ,
|
Txt_levels ,
|
||||||
|
@ -3994,15 +3996,16 @@ static void Brw_ShowSizeOfFileTree (void)
|
||||||
Txt_folders,
|
Txt_folders,
|
||||||
Gbl.FileBrowser.Size.NumFiles,
|
Gbl.FileBrowser.Size.NumFiles,
|
||||||
Gbl.FileBrowser.Size.NumFiles == 1 ? Txt_file :
|
Gbl.FileBrowser.Size.NumFiles == 1 ? Txt_file :
|
||||||
Txt_files);
|
Txt_files,
|
||||||
Str_WriteSizeInBytesFull ((double) Gbl.FileBrowser.Size.TotalSiz);
|
FileSizeStr);
|
||||||
if (Gbl.FileBrowser.Size.MaxQuota)
|
if (Gbl.FileBrowser.Size.MaxQuota)
|
||||||
{
|
{
|
||||||
fprintf (Gbl.F.Out," (%.1f%% %s ",
|
Fil_WriteFileSizeBrief ((double) Gbl.FileBrowser.Size.MaxQuota,FileSizeStr);
|
||||||
100.0 * ((double) Gbl.FileBrowser.Size.TotalSiz / (double) Gbl.FileBrowser.Size.MaxQuota),
|
fprintf (Gbl.F.Out," (%.1f%% %s %s)",
|
||||||
Txt_of_PART_OF_A_TOTAL);
|
100.0 * ((double) Gbl.FileBrowser.Size.TotalSiz /
|
||||||
Str_WriteSizeInBytesBrief ((double) Gbl.FileBrowser.Size.MaxQuota);
|
(double) Gbl.FileBrowser.Size.MaxQuota),
|
||||||
fprintf (Gbl.F.Out,")");
|
Txt_of_PART_OF_A_TOTAL,
|
||||||
|
FileSizeStr);
|
||||||
}
|
}
|
||||||
fprintf (Gbl.F.Out,"</div>");
|
fprintf (Gbl.F.Out,"</div>");
|
||||||
}
|
}
|
||||||
|
@ -6150,14 +6153,18 @@ static void Brw_WriteFileSizeAndDate (Brw_FileType_t FileType,struct FileMetadat
|
||||||
{
|
{
|
||||||
extern const char *Txt_Today;
|
extern const char *Txt_Today;
|
||||||
static unsigned UniqueId = 0;
|
static unsigned UniqueId = 0;
|
||||||
|
char FileSizeStr[Fil_MAX_BYTES_FILE_SIZE_STRING];
|
||||||
|
|
||||||
/***** Write the file size *****/
|
/***** Write the file size *****/
|
||||||
fprintf (Gbl.F.Out,"<td class=\"%s RIGHT_MIDDLE COLOR%u\">"
|
|
||||||
" ",
|
|
||||||
Gbl.FileBrowser.TxtStyle,Gbl.RowEvenOdd);
|
|
||||||
if (FileType == Brw_IS_FILE)
|
if (FileType == Brw_IS_FILE)
|
||||||
Str_WriteSizeInBytesBrief ((double) FileMetadata->Size);
|
Fil_WriteFileSizeBrief ((double) FileMetadata->Size,FileSizeStr);
|
||||||
fprintf (Gbl.F.Out,"</td>");
|
else
|
||||||
|
FileSizeStr[0] = '\0';
|
||||||
|
fprintf (Gbl.F.Out,"<td class=\"%s RIGHT_MIDDLE COLOR%u\">"
|
||||||
|
" %s"
|
||||||
|
"</td>",
|
||||||
|
Gbl.FileBrowser.TxtStyle,Gbl.RowEvenOdd,
|
||||||
|
FileSizeStr);
|
||||||
|
|
||||||
/***** Write the date *****/
|
/***** Write the date *****/
|
||||||
fprintf (Gbl.F.Out,"<td class=\"%s RIGHT_MIDDLE COLOR%u\">"
|
fprintf (Gbl.F.Out,"<td class=\"%s RIGHT_MIDDLE COLOR%u\">"
|
||||||
|
@ -9193,6 +9200,7 @@ void Brw_ShowFileMetadata (void)
|
||||||
struct UsrData PublisherUsrDat;
|
struct UsrData PublisherUsrDat;
|
||||||
char FileNameToShow[NAME_MAX+1];
|
char FileNameToShow[NAME_MAX+1];
|
||||||
char URL[PATH_MAX+1];
|
char URL[PATH_MAX+1];
|
||||||
|
char FileSizeStr[Fil_MAX_BYTES_FILE_SIZE_STRING];
|
||||||
bool Found;
|
bool Found;
|
||||||
bool ICanView = false;
|
bool ICanView = false;
|
||||||
bool ICanEdit;
|
bool ICanEdit;
|
||||||
|
@ -9378,32 +9386,34 @@ void Brw_ShowFileMetadata (void)
|
||||||
Usr_UsrDataDestructor (&PublisherUsrDat);
|
Usr_UsrDataDestructor (&PublisherUsrDat);
|
||||||
|
|
||||||
/***** Write the file size *****/
|
/***** Write the file size *****/
|
||||||
|
Fil_WriteFileSizeFull ((double) FileMetadata.Size,FileSizeStr);
|
||||||
fprintf (Gbl.F.Out,"<tr>"
|
fprintf (Gbl.F.Out,"<tr>"
|
||||||
"<td class=\"%s RIGHT_MIDDLE\">"
|
"<td class=\"%s RIGHT_MIDDLE\">"
|
||||||
"%s:"
|
"%s:"
|
||||||
"</td>"
|
"</td>"
|
||||||
"<td class=\"DAT LEFT_MIDDLE\">",
|
"<td class=\"DAT LEFT_MIDDLE\">"
|
||||||
The_ClassForm[Gbl.Prefs.Theme],Txt_File_size);
|
"%s"
|
||||||
Str_WriteSizeInBytesFull ((double) FileMetadata.Size);
|
"</td>"
|
||||||
fprintf (Gbl.F.Out,"</td>"
|
"</tr>",
|
||||||
"</tr>");
|
The_ClassForm[Gbl.Prefs.Theme],
|
||||||
|
Txt_File_size,
|
||||||
|
FileSizeStr);
|
||||||
|
|
||||||
/***** Write the date *****/
|
/***** Write the date *****/
|
||||||
fprintf (Gbl.F.Out,"<tr>"
|
fprintf (Gbl.F.Out,"<tr>"
|
||||||
"<td class=\"%s RIGHT_MIDDLE\">"
|
"<td class=\"%s RIGHT_MIDDLE\">"
|
||||||
"%s:"
|
"%s:"
|
||||||
"</td>"
|
"</td>"
|
||||||
"<td id=\"filedate\" class=\"DAT LEFT_MIDDLE\">",
|
"<td id=\"filedate\" class=\"DAT LEFT_MIDDLE\">"
|
||||||
The_ClassForm[Gbl.Prefs.Theme],Txt_Date_of_creation);
|
"<script type=\"text/javascript\">"
|
||||||
|
|
||||||
fprintf (Gbl.F.Out,"<script type=\"text/javascript\">"
|
|
||||||
"writeLocalDateHMSFromUTC('filedate',%ld,' ','%s');"
|
"writeLocalDateHMSFromUTC('filedate',%ld,' ','%s');"
|
||||||
"</script>",
|
"</script>"
|
||||||
|
"</td>"
|
||||||
|
"</tr>",
|
||||||
|
The_ClassForm[Gbl.Prefs.Theme],
|
||||||
|
Txt_Date_of_creation,
|
||||||
(long) FileMetadata.Time,Txt_Today);
|
(long) FileMetadata.Time,Txt_Today);
|
||||||
|
|
||||||
fprintf (Gbl.F.Out,"</td>"
|
|
||||||
"</tr>");
|
|
||||||
|
|
||||||
/***** Private or public? *****/
|
/***** Private or public? *****/
|
||||||
fprintf (Gbl.F.Out,"<tr>"
|
fprintf (Gbl.F.Out,"<tr>"
|
||||||
"<td class=\"%s RIGHT_MIDDLE\">"
|
"<td class=\"%s RIGHT_MIDDLE\">"
|
||||||
|
@ -10425,7 +10435,7 @@ void Brw_GetFileMetadataByCod (struct FileMetadata *FileMetadata)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*************************** Get file size and date **************************/
|
/********************** Get file type, size and date *************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
// Return true if file exists
|
// Return true if file exists
|
||||||
|
|
||||||
|
@ -11356,48 +11366,74 @@ 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+(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,char **ContentStr,
|
||||||
long FilCod,unsigned MaxChars,bool GetContent)
|
long FilCod,unsigned MaxChars,bool GetContent)
|
||||||
{
|
{
|
||||||
char Query[256];
|
extern const char *Txt_Filename;
|
||||||
MYSQL_RES *mysql_res;
|
extern const char *Txt_Uploaded_by;
|
||||||
MYSQL_ROW row;
|
extern const char *Txt_ROLES_SINGUL_Abc[Rol_NUM_ROLES][Usr_NUM_SEXS];
|
||||||
char FullPathInTreeFromDB[PATH_MAX+1];
|
extern const char *Txt_File_size;
|
||||||
char PathUntilFileName[PATH_MAX+1];
|
struct FileMetadata FileMetadata;
|
||||||
char FileName[NAME_MAX+1];
|
bool Found;
|
||||||
|
bool FileHasPublisher;
|
||||||
|
struct UsrData PublisherUsrDat;
|
||||||
|
char FileSizeStr[Fil_MAX_BYTES_FILE_SIZE_STRING];
|
||||||
|
|
||||||
|
/***** Return nothing on error *****/
|
||||||
SummaryStr[0] = '\0'; // Return nothing on error
|
SummaryStr[0] = '\0'; // Return nothing on error
|
||||||
|
*ContentStr = NULL;
|
||||||
|
|
||||||
/***** Get subject of message from database *****/
|
/***** Get file metadata *****/
|
||||||
sprintf (Query,"SELECT Path FROM files WHERE FilCod='%ld'",
|
FileMetadata.FilCod = FilCod;
|
||||||
FilCod);
|
Brw_GetFileMetadataByCod (&FileMetadata);
|
||||||
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 data of this file *****/
|
|
||||||
row = mysql_fetch_row (mysql_res);
|
|
||||||
|
|
||||||
/* Path (row[0]) */
|
/***** Get file type, size and date *****/
|
||||||
strncpy (FullPathInTreeFromDB,row[0],PATH_MAX);
|
Gbl.FileBrowser.Type = FileMetadata.FileBrowser;
|
||||||
FullPathInTreeFromDB[PATH_MAX] = '\0';
|
Brw_SetPathFileBrowser ();
|
||||||
Str_SplitFullPathIntoPathAndFileName (FullPathInTreeFromDB,
|
Found = Brw_GetFileTypeSizeAndDate (&FileMetadata);
|
||||||
PathUntilFileName,
|
|
||||||
FileName);
|
/***** Copy file name into summary string *****/
|
||||||
strcpy (SummaryStr,FileName);
|
strcpy (SummaryStr,FileMetadata.FilFolLnkName);
|
||||||
if (MaxChars)
|
if (MaxChars)
|
||||||
Str_LimitLengthHTMLStr (SummaryStr,MaxChars);
|
Str_LimitLengthHTMLStr (SummaryStr,MaxChars);
|
||||||
|
|
||||||
|
/***** Copy some file metadata into content string *****/
|
||||||
if (GetContent)
|
if (GetContent)
|
||||||
{ // TODO: Put file metadata into content string
|
{
|
||||||
if ((*ContentStr = (char *) malloc (strlen (FullPathInTreeFromDB)+1)))
|
if ((*ContentStr = (char *) malloc (Brw_MAX_BYTES_FILE_CONTENT_STR)))
|
||||||
strcpy (*ContentStr,FullPathInTreeFromDB);
|
{
|
||||||
}
|
/* Get publisher */
|
||||||
|
if (FileMetadata.PublisherUsrCod > 0)
|
||||||
|
{
|
||||||
|
/* Initialize structure with publisher's data */
|
||||||
|
Usr_UsrDataConstructor (&PublisherUsrDat);
|
||||||
|
PublisherUsrDat.UsrCod = FileMetadata.PublisherUsrCod;
|
||||||
|
FileHasPublisher = Usr_ChkUsrCodAndGetAllUsrDataFromUsrCod (&PublisherUsrDat);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
/* Unknown publisher */
|
||||||
|
FileHasPublisher = false;
|
||||||
|
|
||||||
mysql_free_result (mysql_res);
|
/* File size */
|
||||||
|
if (Found)
|
||||||
|
Fil_WriteFileSizeFull ((double) FileMetadata.Size,FileSizeStr);
|
||||||
|
|
||||||
|
/* Fill content string */
|
||||||
|
sprintf (*ContentStr,"%s: %s<br />" // File name
|
||||||
|
"%s: %s<br />" // Publisher
|
||||||
|
"%s: %s", // File size
|
||||||
|
Txt_Filename,FileMetadata.FilFolLnkName,
|
||||||
|
Txt_Uploaded_by,FileHasPublisher ? PublisherUsrDat.FullName :
|
||||||
|
Txt_ROLES_SINGUL_Abc[Rol_UNKNOWN][Usr_SEX_UNKNOWN],
|
||||||
|
Txt_File_size,Found ? FileSizeStr :
|
||||||
|
"Not found");
|
||||||
|
|
||||||
|
/* Free memory used for publisher's data */
|
||||||
|
if (FileMetadata.PublisherUsrCod > 0)
|
||||||
|
Usr_UsrDataDestructor (&PublisherUsrDat);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -619,7 +619,6 @@ void Mrk_ShowMyMarks (void)
|
||||||
/***** Get number of rows of header or footer *****/
|
/***** Get number of rows of header or footer *****/
|
||||||
Mrk_GetNumRowsHeaderAndFooter (&Marks);
|
Mrk_GetNumRowsHeaderAndFooter (&Marks);
|
||||||
|
|
||||||
|
|
||||||
/***** Set the student whose marks will be shown *****/
|
/***** Set the student whose marks will be shown *****/
|
||||||
if (Gbl.Usrs.Me.LoggedRole == Rol_STUDENT) // If I am logged as student...
|
if (Gbl.Usrs.Me.LoggedRole == Rol_STUDENT) // If I am logged as student...
|
||||||
UsrDat = &Gbl.Usrs.Me.UsrDat; // ...use my list of IDs
|
UsrDat = &Gbl.Usrs.Me.UsrDat; // ...use my list of IDs
|
||||||
|
|
|
@ -5355,15 +5355,22 @@ static void Sta_WriteRowStatsFileBrowsers (Brw_FileBrowser_t FileZone,const char
|
||||||
char StrNumFilesPerCrs[10+1];
|
char StrNumFilesPerCrs[10+1];
|
||||||
char StrNumFilesPerUsr[10+1];
|
char StrNumFilesPerUsr[10+1];
|
||||||
struct Sta_SizeOfFileZones SizeOfFileZones;
|
struct Sta_SizeOfFileZones SizeOfFileZones;
|
||||||
|
char FileSizeStr[Fil_MAX_BYTES_FILE_SIZE_STRING];
|
||||||
|
char FileSizePerCrsStr[Fil_MAX_BYTES_FILE_SIZE_STRING];
|
||||||
|
char FileSizePerUsrStr[Fil_MAX_BYTES_FILE_SIZE_STRING];
|
||||||
char *Class = (FileZone == Brw_UNKNOWN) ? "DAT_N_LINE_TOP" :
|
char *Class = (FileZone == Brw_UNKNOWN) ? "DAT_N_LINE_TOP" :
|
||||||
"DAT";
|
"DAT";
|
||||||
|
|
||||||
Sta_GetSizeOfFileZoneFromDB (Gbl.Scope.Current,FileZone,&SizeOfFileZones);
|
Sta_GetSizeOfFileZoneFromDB (Gbl.Scope.Current,FileZone,&SizeOfFileZones);
|
||||||
|
|
||||||
|
Fil_WriteFileSizeFull ((double) SizeOfFileZones.Size,FileSizeStr);
|
||||||
|
|
||||||
if (SizeOfFileZones.NumCrss == -1)
|
if (SizeOfFileZones.NumCrss == -1)
|
||||||
{
|
{
|
||||||
strcpy (StrNumCrss ,"-");
|
strcpy (StrNumCrss ,"-");
|
||||||
strcpy (StrNumFoldersPerCrs,"-");
|
strcpy (StrNumFoldersPerCrs,"-");
|
||||||
strcpy (StrNumFilesPerCrs ,"-");
|
strcpy (StrNumFilesPerCrs ,"-");
|
||||||
|
strcpy (FileSizePerCrsStr ,"-");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -5376,6 +5383,10 @@ static void Sta_WriteRowStatsFileBrowsers (Brw_FileBrowser_t FileZone,const char
|
||||||
SizeOfFileZones.NumCrss ? (double) SizeOfFileZones.NumFiles /
|
SizeOfFileZones.NumCrss ? (double) SizeOfFileZones.NumFiles /
|
||||||
(double) SizeOfFileZones.NumCrss :
|
(double) SizeOfFileZones.NumCrss :
|
||||||
0.0);
|
0.0);
|
||||||
|
Fil_WriteFileSizeFull (SizeOfFileZones.NumCrss ? (double) SizeOfFileZones.Size /
|
||||||
|
(double) SizeOfFileZones.NumCrss :
|
||||||
|
0.0,
|
||||||
|
FileSizePerCrsStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SizeOfFileZones.NumGrps == -1)
|
if (SizeOfFileZones.NumGrps == -1)
|
||||||
|
@ -5388,6 +5399,7 @@ static void Sta_WriteRowStatsFileBrowsers (Brw_FileBrowser_t FileZone,const char
|
||||||
strcpy (StrNumUsrs ,"-");
|
strcpy (StrNumUsrs ,"-");
|
||||||
strcpy (StrNumFoldersPerUsr,"-");
|
strcpy (StrNumFoldersPerUsr,"-");
|
||||||
strcpy (StrNumFilesPerUsr ,"-");
|
strcpy (StrNumFilesPerUsr ,"-");
|
||||||
|
strcpy (FileSizePerUsrStr ,"-");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -5400,7 +5412,12 @@ static void Sta_WriteRowStatsFileBrowsers (Brw_FileBrowser_t FileZone,const char
|
||||||
SizeOfFileZones.NumUsrs ? (double) SizeOfFileZones.NumFiles /
|
SizeOfFileZones.NumUsrs ? (double) SizeOfFileZones.NumFiles /
|
||||||
(double) SizeOfFileZones.NumUsrs :
|
(double) SizeOfFileZones.NumUsrs :
|
||||||
0.0);
|
0.0);
|
||||||
|
Fil_WriteFileSizeFull (SizeOfFileZones.NumUsrs ? (double) SizeOfFileZones.Size /
|
||||||
|
(double) SizeOfFileZones.NumUsrs :
|
||||||
|
0.0,
|
||||||
|
FileSizePerUsrStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf (Gbl.F.Out,"<tr>"
|
fprintf (Gbl.F.Out,"<tr>"
|
||||||
"<td class=\"%s LEFT_MIDDLE\">"
|
"<td class=\"%s LEFT_MIDDLE\">"
|
||||||
"%s"
|
"%s"
|
||||||
|
@ -5423,7 +5440,28 @@ static void Sta_WriteRowStatsFileBrowsers (Brw_FileBrowser_t FileZone,const char
|
||||||
"<td class=\"%s RIGHT_MIDDLE\">"
|
"<td class=\"%s RIGHT_MIDDLE\">"
|
||||||
"%lu"
|
"%lu"
|
||||||
"</td>"
|
"</td>"
|
||||||
"<td class=\"%s RIGHT_MIDDLE\">",
|
"<td class=\"%s RIGHT_MIDDLE\">"
|
||||||
|
"%s"
|
||||||
|
"</td>"
|
||||||
|
"<td class=\"%s RIGHT_MIDDLE\">"
|
||||||
|
"%s"
|
||||||
|
"</td>"
|
||||||
|
"<td class=\"%s RIGHT_MIDDLE\">"
|
||||||
|
"%s"
|
||||||
|
"</td>"
|
||||||
|
"<td class=\"%s RIGHT_MIDDLE\">"
|
||||||
|
"%s"
|
||||||
|
"</td>"
|
||||||
|
"<td class=\"%s RIGHT_MIDDLE\">"
|
||||||
|
"%s"
|
||||||
|
"</td>"
|
||||||
|
"<td class=\"%s RIGHT_MIDDLE\">"
|
||||||
|
"%s"
|
||||||
|
"</td>"
|
||||||
|
"<td class=\"%s RIGHT_MIDDLE\">"
|
||||||
|
"%s"
|
||||||
|
"</td>"
|
||||||
|
"</tr>",
|
||||||
Class,NameOfFileZones,
|
Class,NameOfFileZones,
|
||||||
Class,StrNumCrss,
|
Class,StrNumCrss,
|
||||||
Class,StrNumGrps,
|
Class,StrNumGrps,
|
||||||
|
@ -5431,44 +5469,13 @@ static void Sta_WriteRowStatsFileBrowsers (Brw_FileBrowser_t FileZone,const char
|
||||||
Class,SizeOfFileZones.MaxLevels,
|
Class,SizeOfFileZones.MaxLevels,
|
||||||
Class,SizeOfFileZones.NumFolders,
|
Class,SizeOfFileZones.NumFolders,
|
||||||
Class,SizeOfFileZones.NumFiles,
|
Class,SizeOfFileZones.NumFiles,
|
||||||
Class);
|
Class,FileSizeStr,
|
||||||
Str_WriteSizeInBytesFull ((double) SizeOfFileZones.Size);
|
|
||||||
fprintf (Gbl.F.Out,"</td>"
|
|
||||||
"<td class=\"%s RIGHT_MIDDLE\">"
|
|
||||||
"%s"
|
|
||||||
"</td>"
|
|
||||||
"<td class=\"%s RIGHT_MIDDLE\">"
|
|
||||||
"%s"
|
|
||||||
"</td>"
|
|
||||||
"<td class=\"%s RIGHT_MIDDLE\">",
|
|
||||||
Class,StrNumFoldersPerCrs,
|
Class,StrNumFoldersPerCrs,
|
||||||
Class,StrNumFilesPerCrs,
|
Class,StrNumFilesPerCrs,
|
||||||
Class);
|
Class,FileSizePerCrsStr,
|
||||||
if (SizeOfFileZones.NumCrss == -1)
|
|
||||||
fprintf (Gbl.F.Out,"-");
|
|
||||||
else
|
|
||||||
Str_WriteSizeInBytesFull (SizeOfFileZones.NumCrss ? (double) SizeOfFileZones.Size /
|
|
||||||
(double) SizeOfFileZones.NumCrss :
|
|
||||||
0.0);
|
|
||||||
fprintf (Gbl.F.Out,"</td>"
|
|
||||||
"<td class=\"%s RIGHT_MIDDLE\">"
|
|
||||||
"%s"
|
|
||||||
"</td>"
|
|
||||||
"<td class=\"%s RIGHT_MIDDLE\">"
|
|
||||||
"%s"
|
|
||||||
"</td>"
|
|
||||||
"<td class=\"%s RIGHT_MIDDLE\">",
|
|
||||||
Class,StrNumFoldersPerUsr,
|
Class,StrNumFoldersPerUsr,
|
||||||
Class,StrNumFilesPerUsr,
|
Class,StrNumFilesPerUsr,
|
||||||
Class);
|
Class,FileSizePerUsrStr);
|
||||||
if (SizeOfFileZones.NumUsrs == -1)
|
|
||||||
fprintf (Gbl.F.Out,"-");
|
|
||||||
else
|
|
||||||
Str_WriteSizeInBytesFull (SizeOfFileZones.NumUsrs ? (double) SizeOfFileZones.Size /
|
|
||||||
(double) SizeOfFileZones.NumUsrs :
|
|
||||||
0.0);
|
|
||||||
fprintf (Gbl.F.Out,"</td>"
|
|
||||||
"</tr>");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -2759,53 +2759,6 @@ void Str_ConvertToValidFileName (char *Str)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/********** Write a quantity of bytes as bytes, KiB, MiB, GiB or TiB *********/
|
|
||||||
/*****************************************************************************/
|
|
||||||
|
|
||||||
#define Ki 1024.0
|
|
||||||
#define Mi 1048576.0
|
|
||||||
#define Gi 1073741824.0
|
|
||||||
#define Ti 1099511627776.0
|
|
||||||
|
|
||||||
void Str_WriteSizeInBytesBrief (double SizeInBytes)
|
|
||||||
{
|
|
||||||
if (SizeInBytes < Ki)
|
|
||||||
fprintf (Gbl.F.Out,"%.0f B",
|
|
||||||
SizeInBytes);
|
|
||||||
else if (SizeInBytes < Mi)
|
|
||||||
fprintf (Gbl.F.Out,"%.0f KiB",
|
|
||||||
SizeInBytes / Ki);
|
|
||||||
else if (SizeInBytes < Gi)
|
|
||||||
fprintf (Gbl.F.Out,"%.0f MiB",
|
|
||||||
SizeInBytes / Mi);
|
|
||||||
else if (SizeInBytes < Ti)
|
|
||||||
fprintf (Gbl.F.Out,"%.0f GiB",
|
|
||||||
SizeInBytes / Gi);
|
|
||||||
else
|
|
||||||
fprintf (Gbl.F.Out,"%.0f TiB",
|
|
||||||
SizeInBytes / Ti);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Str_WriteSizeInBytesFull (double SizeInBytes)
|
|
||||||
{
|
|
||||||
if (SizeInBytes < Ki)
|
|
||||||
fprintf (Gbl.F.Out,"%.0f B",
|
|
||||||
SizeInBytes);
|
|
||||||
else if (SizeInBytes < Mi)
|
|
||||||
fprintf (Gbl.F.Out,"%.1f KiB",
|
|
||||||
SizeInBytes / Ki);
|
|
||||||
else if (SizeInBytes < Gi)
|
|
||||||
fprintf (Gbl.F.Out,"%.1f MiB",
|
|
||||||
SizeInBytes / Mi);
|
|
||||||
else if (SizeInBytes < Ti)
|
|
||||||
fprintf (Gbl.F.Out,"%.1f GiB",
|
|
||||||
SizeInBytes / Gi);
|
|
||||||
else
|
|
||||||
fprintf (Gbl.F.Out,"%.1f TiB",
|
|
||||||
SizeInBytes / Ti);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/******************* Create a random alphanumeric string *********************/
|
/******************* Create a random alphanumeric string *********************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
|
@ -115,8 +115,7 @@ int Str_ReadFileUntilBoundaryStr (FILE *FileSrc,char *StrDst,
|
||||||
unsigned long long MaxLength);
|
unsigned long long MaxLength);
|
||||||
bool Str_ConvertFilFolLnkNameToValid (char *FileName);
|
bool Str_ConvertFilFolLnkNameToValid (char *FileName);
|
||||||
void Str_ConvertToValidFileName (char *Str);
|
void Str_ConvertToValidFileName (char *Str);
|
||||||
void Str_WriteSizeInBytesBrief (double SizeInBytes);
|
|
||||||
void Str_WriteSizeInBytesFull (double SizeInBytes);
|
|
||||||
void Str_CreateRandomAlphanumStr (char *Str,size_t Length);
|
void Str_CreateRandomAlphanumStr (char *Str,size_t Length);
|
||||||
void Str_GetMailBox (const char *Email,char *MailBox,size_t MaxLength);
|
void Str_GetMailBox (const char *Email,char *MailBox,size_t MaxLength);
|
||||||
|
|
||||||
|
|
|
@ -98,8 +98,5 @@ void Syl_WriteStartFileSyllabus (FILE *FileSyllabus);
|
||||||
void Syl_WriteAllItemsFileSyllabus (FILE *FileSyllabus);
|
void Syl_WriteAllItemsFileSyllabus (FILE *FileSyllabus);
|
||||||
void Syl_WriteItemFileSyllabus (FILE *FileSyllabus,int Level,const char *Text);
|
void Syl_WriteItemFileSyllabus (FILE *FileSyllabus,int Level,const char *Text);
|
||||||
void Syl_WriteEndFileSyllabus (FILE *FileSyllabus);
|
void Syl_WriteEndFileSyllabus (FILE *FileSyllabus);
|
||||||
void Fil_CloseXMLFile (void);
|
|
||||||
void XML_WriteStartFile (FILE *FileTgt,const char *Type,bool Credits);
|
|
||||||
void XML_WriteEndFile (FILE *FileTgt,const char *Type);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -112,6 +112,7 @@ cp -f /home/acanas/swad/swad/swad /var/www/cgi-bin/
|
||||||
#include "swad_search.h"
|
#include "swad_search.h"
|
||||||
#include "swad_user.h"
|
#include "swad_user.h"
|
||||||
#include "swad_web_service.h"
|
#include "swad_web_service.h"
|
||||||
|
#include "swad_xml.h"
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/************** External global variables from others modules ****************/
|
/************** External global variables from others modules ****************/
|
||||||
|
|
16
swad_zip.c
16
swad_zip.c
|
@ -575,6 +575,7 @@ static void ZIP_ShowLinkToDownloadZIP (const char *FileName,const char *URL,
|
||||||
extern const char *Txt_File_size;
|
extern const char *Txt_File_size;
|
||||||
extern const char *Txt_FILE_uncompressed;
|
extern const char *Txt_FILE_uncompressed;
|
||||||
char FileNameShort[NAME_MAX+1];
|
char FileNameShort[NAME_MAX+1];
|
||||||
|
char FileSizeStr[Fil_MAX_BYTES_FILE_SIZE_STRING];
|
||||||
|
|
||||||
/***** Limit length of the name of the file *****/
|
/***** Limit length of the name of the file *****/
|
||||||
strncpy (FileNameShort,FileName,NAME_MAX);
|
strncpy (FileNameShort,FileName,NAME_MAX);
|
||||||
|
@ -620,18 +621,21 @@ static void ZIP_ShowLinkToDownloadZIP (const char *FileName,const char *URL,
|
||||||
URL,FileName,FileName);
|
URL,FileName,FileName);
|
||||||
|
|
||||||
/***** Write the file size *****/
|
/***** Write the file size *****/
|
||||||
|
Fil_WriteFileSizeFull ((double) FileSize,FileSizeStr);
|
||||||
fprintf (Gbl.F.Out,"<tr>"
|
fprintf (Gbl.F.Out,"<tr>"
|
||||||
"<td class=\"%s RIGHT_MIDDLE\">"
|
"<td class=\"%s RIGHT_MIDDLE\">"
|
||||||
"%s:"
|
"%s:"
|
||||||
"</td>"
|
"</td>"
|
||||||
"<td class=\"DAT LEFT_MIDDLE\">",
|
"<td class=\"DAT LEFT_MIDDLE\">"
|
||||||
The_ClassForm[Gbl.Prefs.Theme],Txt_File_size);
|
"%s",
|
||||||
Str_WriteSizeInBytesFull ((double) FileSize);
|
The_ClassForm[Gbl.Prefs.Theme],
|
||||||
|
Txt_File_size,
|
||||||
|
FileSizeStr);
|
||||||
if (UncompressedSize)
|
if (UncompressedSize)
|
||||||
{
|
{
|
||||||
fprintf (Gbl.F.Out," (");
|
Fil_WriteFileSizeFull ((double) UncompressedSize,FileSizeStr);
|
||||||
Str_WriteSizeInBytesFull ((double) UncompressedSize);
|
fprintf (Gbl.F.Out," (%s %s)",
|
||||||
fprintf (Gbl.F.Out," %s)",Txt_FILE_uncompressed);
|
FileSizeStr,Txt_FILE_uncompressed);
|
||||||
}
|
}
|
||||||
fprintf (Gbl.F.Out,"</td>"
|
fprintf (Gbl.F.Out,"</td>"
|
||||||
"</tr>");
|
"</tr>");
|
||||||
|
|
Loading…
Reference in New Issue