/usr/lib/wims/bin/mkpopular is in wims 1:4.07d~dfsg1-1ubuntu2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | #! /bin/sh
#
# This script sorts modules according to their popularity.
# It can be run whenever you like, if your site has the
# traffic accounting activated.
# However, if your site does not have a very high trafic,
# it is better never to run it, in order to preserve the
# popularity register files coming with the wims distribution
# which are based on the statistics of the popular wims home server.
#
# base directory.
WIMS_HOME=`dirname $0`/..
cd $WIMS_HOME
WIMS_HOME=`pwd`
if [ ! -f log/account/00access.act ]; then
echo Site accounting not available.
exit
fi
# bonus for new modules
bonus=1500
# start and end date
start=`date -d '12 months ago' '+%Y%m%d'`
end=`date -d '1 day ago' '+%Y%m%d'`
endd=`date -d '1 day ago' '+%j'`
endy=`date -d '1 day ago' '+%Y'`
endt=`date -d '31 Dec' '+%j'`
cd log/account
stated=`ls [A-Z]* tool* contrib* | grep '@'`
rm -f $WIMS_HOME/tmp/pop* >/dev/null 2>&1
for m in $stated
do
echo $m
mm=`echo $m | sed 's/\.[a-z][a-z]$/.??/g'`
cat $mm 2>/dev/null | sort -n >$WIMS_HOME/tmp/m
access=`awk 'BEGIN {a=0;b=0;};
$1>'$start' && $1<'$end' {a=a+sqrt($2);b++;};
END {print int(50*a)};' $WIMS_HOME/tmp/m`
beg=`awk '{print $1; exit}' $WIMS_HOME/tmp/m`
if [ -z $beg ]; then
access=0
laps=2
else
if [ $beg -lt $start ]; then beg=$start; fi
begd=`date -d $beg '+%j'`
begy=`date -d $beg '+%Y'`
begt=`date -d "31 Dec $begy" '+%j'`
laps=`expr 365 \* \( $endy - $begy \) + \( $endd - $begd \) + $begt - 365 + 1`
fi
pop=`expr \( $access + $bonus \) / $laps`
echo $m:$m $pop >>$WIMS_HOME/tmp/pop1
echo $m:$pop >>$WIMS_HOME/tmp/pop2
done
cd $WIMS_HOME
tr @ / <tmp/pop1 >tmp/popp
tr @ / <tmp/pop2 >tmp/popv
sort -n -r -k2 <tmp/popp >tmp/pop1.sorted
bin/dicsort tmp/popp
bin/dicsort tmp/popv
mv tmp/pop1.sorted public_html/bases/site/lists/popular
mv tmp/popp.sorted public_html/bases/site/pop/dic
mv tmp/popv.sorted public_html/bases/site/popular
rm -f tmp/pop* tmp/m >/dev/null 2>&1
|