@/*description:
{
It updates the number of hits done on project page. The history saves all remote hosts
that have already loaded the page, and keeps the number of hits by date for each
remote host.
To make it persistent, these data are saved in a file \samp{"hitCounter.txt"}, which is
parsed via the script \samp{"hitCounterParser.cwp"}. The file is updated by generating
it via the \textit{template-based} script \samp{"hitCounterUpdate.cwt"}.
}
output "examples/hitCounter.txt", "examples/hitCounter.html";
*/
if existFile("hitCounter.txt") {
parseAsBNF("hitCounterParser.cwp", project, "hitCounter.txt");
saveProject("hitCounter.xml");
}
increment(project.hits);
local sDate = formatDate(getNow(), "%d%b%Y");
increment(project.dates[sDate].hits);
local sHost = getEnv("REMOTE_HOST");
insert project.hosts[sHost] = sHost;
increment(project.hosts[sHost].hits);
increment(project.hosts[sHost].dates[sDate].hits);
saveProject("hitCounter1.xml");
generate("hitCounterUpdate.cwt", project, "hitCounter.txt");
@
Number of hits: @project.hits@ |
@
foreach i in project.hosts {
@
@key(i)@ | @i.hits@ |
@
}
@
Hits by date |
@
foreach i in project.dates {
@
@key(i)@ | @i.hits@ |
@
}
@