\param name A buffer to write the real name of the user.
\param namelen The size of the buffer.
*/
+
+
+
+
+
+/*! \fn int is_download_suffix(const char *url)
+Tell if the URL correspond to a downloaded file. The function takes the extension at the end of the
+URL with a maximum of 9 characters and compare it to the list of the download suffix in
+::DownloadSuffix. If the suffix is found in the list, the function reports the URL as the download
+of a file.
+
+\param url The URL to test.
+
+\retval 1 The URL matches a suffix of a download.
+\retval 0 The URL is not a known download.
+
+\note A downloaded file cannot be detected if the file name is embedded in a GET or POST request. Only requests
+that ends with the file name can be detected.
+
+\note A URL embedding another web site's address ending by .com at the end of the URL will match the download
+extension com if it is defined in the ::DownloadSuffix.
+*/
char user2[MAXLEN];
char wentp[512];
char addr[MAXLEN];
-char suffix[10];
-char download_url[MAXLEN];
char Ulimit[6];
char RealtimeTypes[1024];
char cmd[255];
int DansGuardianReportLimit;
int SquidGuardReportLimit;
int UserReportLimit;
-int download_flag;
int dotinuser;
int realtime_refresh;
int realtime_access_log_lines;
void read_usertab(const char *UserTabFile);
void get_usertab_name(const char *user,char *name,int namelen);
int compar( const void *, const void * );
+int is_download_suffix(const char *url);
unsigned long recs2=0;
struct rlimit rl;
int OutputNonZero = REPORT_EVERY_X_LINES ;
+ int download_flag;
+ char download_url[MAXLEN];
BgImage[0]='\0';
LogoImage[0]='\0';
if(strstr(ReportType,"denied") != 0)
strcpy(urly,url);
- if(strlen(DownloadSuffix)) {
- suffix[0]='\0';
- download_flag=0;
- if(strncmp(url+strlen(url)-4,".",1) == 0)
- strcpy(suffix,url+strlen(url)-3);
- else strcpy(suffix,url+strlen(url)-4);
- if(strstr(DownloadSuffix,suffix) != 0) {
- strcpy(download_url,url);
- download_flag=1;
- download_count++;
- }
+ download_flag=is_download_suffix(url);
+ if (download_flag) {
+ strcpy(download_url,url);
+ download_count++;
}
if (strchr(url,'/')) {
}
}
}
+
+int is_download_suffix(const char *url)
+{
+ int urllen;
+ int i;
+ char suffix[10];
+ const char *str;
+ int suflen;
+
+ if(DownloadSuffix[0]==0) return(0);
+
+ urllen=strlen(url)-1;
+ for (i=0 ; i<sizeof(suffix)-1 && i<urllen ; i++) {
+ if (url[urllen-i]=='.') {
+ if (i==0) return(0); //detect a single trailing dot
+ strcpy(suffix,url+urllen-i+1);
+ suflen=strlen(suffix);
+ for (str=DownloadSuffix ; str ; str=strchr(str,',')) {
+ if (*str==',') str++;
+ if(strncasecmp(str,suffix,suflen)==0 && (str[suflen]==',' || str[suflen]==0))
+ return(1);
+ }
+ return(0);
+ }
+ }
+ return(0);
+}
+