Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for simple stand-alone web analytics borrowed from mkws #827

Open
silverhook opened this issue Mar 4, 2022 · 1 comment
Open

Comments

@silverhook
Copy link
Member

I recently stumbled upon this very lightweight and elegant solution to some simple web analytics.

It tracks:

  • top referrers
  • top pages
  • visits
  • unique visitors

Demo: https://s.mkws.sh/

I am pasting the full source code below, but apart from the small fl tool, I don’t know if some of the (re)sources (e.g. share/myips and share/bots) are not part of mkws.

#!
rgrep() {
fgrep "$1" "$2" | grep -vf share/myips -ivf share/bots
}
lr(){
rgrep "$1" "$2" | flvr | sort -nrk 2
}
lp(){
rgrep "$1" "$2" | flvp | sort -nrk 2
}
lv(){
rgrep "$1" "$2" | flvv | wc -l | tr -d " "
}
lu(){
rgrep "$1" "$2" | flvu | wc -l | tr -d " "
}
stats() {
#!
<table>
<caption>$1</caption>
<tr>
<th>
Referrers
</th>
<td>
<ul>
#!
lr "$1" "$2"  | while read -r u c
do
#!
<li><a href=$u>$u</a> - $c</li>
#!
done
#!
</ul>
</td>
</tr>
<tr>
<th>
Pages
</th>
<td>
<ul>
#!
lp "$1" "$2"  | while read -r u c
do
#!
<li><a href=//mkws.sh$u>$u</a> - $c</li>
#!
done
#!
</ul>
</td>
</tr>
<tr>
<th>Visits</th>
<td>
#!
lv "$1" "$2"
#!
</td>
</tr>
<tr>
<th>Uniques</th>
<td>
#!
lu "$1" "$2"
#!
</td>
</tr>
</table>
#!
}
#!
<h1><a href=https://mkws.sh>mkws.sh</a> statistics</h1>
#!
stats "$(date +'%d/%b/%Y')" /var/www/logs/mkws.shaccess.log
#!
@adriangrigore
Copy link

mkws maker here.

Ok, share/myips are just my IP addresses I prefer excluded from the statistics.

share/bots has been replaced by https://adi.onl/cblfb.html

fl is either https://adi.onl/cl.html, https://adi.onl/cbl.html or https://adi.onl/fl.html.

I removed the source code from http://s.mkws.sh/, might have been a bad idea. I'm considering releasing a stand alone analytics package based on those ideas.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants