output_html_url(fp_ou,url);
fputs("\"><img src=\"../images/sarg-squidguard-block.png\"></a> ",fp_ou);
}
- output_html_link(fp_ou,"",url,100); //the original scheme is left in the URL
+ output_html_link(fp_ou,url,100);
fputs("</td></th>\n",fp_ou);
}
fclose(fp_in);
}
fprintf(fp_ou,"<tr><td class=\"data2\">%s</td><td class=\"data2\">%s</td><td class=\"data2\">%s-%s</td><td class=\"data2\">",name,ip,date,hour);
- output_html_link(fp_ou,NULL,url,100);
+ output_html_link(fp_ou,url,100);
fprintf(fp_ou,"</td><td class=\"data2\">%s</td></tr>\n",rule);
}
fclose(fp_in);
output_html_url(fp_ou,url);
fprintf(fp_ou,"\"><img src=\"%s/sarg-squidguard-block.png\"></a> ",ImageFile);
}
- output_html_link(fp_ou,"",url,100); //the URL contains the scheme
+ output_html_link(fp_ou,url,100);
fputs("</td></tr>\n",fp_ou);
}
fclose(fp_in);
output_html_url(fp_ou,url);
fprintf(fp_ou,"\"><img src=\"%s/sarg-squidguard-block.png\"></a> ",ImageFile);
}
- output_html_link(fp_ou,"",url,100);//scheme is kept from the log file
+ output_html_link(fp_ou,url,100);
fputs("</td></tr>\n",fp_ou);
}
fclose(fp_in);
output_html_url(fp_ou,url);
fprintf(fp_ou,"\"><img src=\"%s/sarg-squidguard-block.png\"></a> ",tmp6);
}
- output_html_link(fp_ou,NULL,url,100);
+ output_html_link(fp_ou,url,100);
fputs("</td>",fp_ou);
}
// url.c
void read_hostalias(const char *Filename);
void free_hostalias(void);
+const char *skip_scheme(const char *url);
const char *process_url(char *url,bool full_url);
void url_hostname(const char *url,char *hostname,int hostsize);
__attribute__((warn_unused_result)) int write_html_trailer(FILE *fp_ou);
void output_html_string(FILE *fp_ou,const char *str,int maxlen);
void output_html_url(FILE *fp_ou,const char *url);
-void output_html_link(FILE *fp_ou,const char *scheme,const char *url,int maxlen);
+void output_html_link(FILE *fp_ou,const char *url,int maxlen);
void debuga(const char *msg,...) __attribute__((format(printf,1,2)));
void debugaz(const char *msg,...) __attribute__((format(printf,1,2)));
void my_lltoa(unsigned long long int n, char *s, int ssize, int len);
else
fputs("<tr><td class=\"data2\"></td><td class=\"data2\"></td>",fp_ou);
fprintf(fp_ou,"<td class=\"data2\">%s-%s</td><td class=\"data2\">",data,hora);
- output_html_link(fp_ou,NULL,url,100);
+ output_html_link(fp_ou,url,100);
fprintf(fp_ou,"</td><td class=\"data2\">%s</td></tr>\n",rule);
}
fclose(fp_in);
output_html_url(fp_ou,ourl);
fputs("\"><img src=\"../images/sarg-squidguard-block.png\"></a> ",fp_ou);
}
- output_html_link(fp_ou,NULL,ourl,100);
+ output_html_link(fp_ou,ourl,100);
fputs("</td>",fp_ou);
if (BytesInSitesUsersReport) {
fputs("\"><img src=\"../images/sarg-squidguard-block.png\"></a> ",fp_ou);
}
- output_html_link(fp_ou,NULL,url,100);
+ output_html_link(fp_ou,url,100);
fputs("</td><td class=\"data\"",fp_ou);
if (SortTableJs[0]) fprintf(fp_ou," sorttable_customkey=\"%"PRId64"\"",(uint64_t)twork1);
fprintf(fp_ou,">%s</td>",fixnum(twork1,1));
return(url);
}
+/*!
+Find the beginning of the URL beyond the scheme://
+
+\param url The url possibly containing a scheme.
+
+\return The beginning of the url beyond the scheme.
+*/
+const char *skip_scheme(const char *url)
+{
+ const char *str;
+
+ /*
+ Skip any scheme:// at the beginning of the URL (see rfc2396 section 3.1).
+ The underscore is not part of the standard but is found in the squid logs as cache_object://.
+ */
+ for (str=url ; *str && (isalnum(*str) || *str=='+' || *str=='-' || *str=='.' || *str=='_') ; str++);
+ if (str[0]==':' && str[1]=='/' && str[2]=='/') {
+ url=str+3;
+ while (*url=='/') url++;
+ }
+ return(url);
+}
+
/*!
Get the part of the URL necessary to generate the report.
unsigned short int ipv6[8];
const char *next;
- /*
- Remove any scheme:// at the beginning of the URL (see rfc2396 section 3.1).
- The underscore is not part of the standard but is found in the squid logs as cache_object://.
- */
- for (str=url ; *str && (isalnum(*str) || *str=='+' || *str=='-' || *str=='.' || *str=='_') ; str++);
- if (*str==':' && str[1]=='/' && str[2]=='/') {
- url=str+3;
- while (*url=='/') url++;
- }
-
- start=url;
+ start=skip_scheme(url);
if (!full_url) {
- for (str=url ; *str && *str!='/' && *str!='?' ; str++);
+ for (str=(char *)start ; *str && *str!='/' && *str!='?' ; str++);
*str='\0';
- type=extract_address_mask(url,&address,ipv4,ipv6,NULL,&next);
+ type=extract_address_mask(start,&address,ipv4,ipv6,NULL,&next);
if (type==1) {
if (FirstAliasName)
start=alias_url_name(start,next);
so the A tag is not written around the host name.
\param fp_ou The handle of the HTML file.
- \param scheme The scheme to print in the link (http:// if the pointer is null).
\param url The host to display in the HTML file.
\param maxlen The maximum number of characters to print into the host name.
*/
-void output_html_link(FILE *fp_ou,const char *scheme,const char *url,int maxlen)
+void output_html_link(FILE *fp_ou,const char *url,int maxlen)
{
if (url[0]==ALIAS_PREFIX) {
// this is an alias, no need for a A tag
output_html_string(fp_ou,url+1,100);
} else {
- if (scheme==NULL) scheme="http://";
- fprintf(fp_ou,"<a href=\"%s",scheme);
+ if (skip_scheme(url)==url)
+ fputs("<a href=\"http://",fp_ou);//no scheme in the url, assume http:// to make the link clickable
+ else
+ fputs("<a href=\"",fp_ou);//the scheme is in the url, no need to add one
output_html_url(fp_ou,url);
fputs("\">",fp_ou);
output_html_string(fp_ou,url,100);