29 lines
1.0 KiB
Bash
Executable File
29 lines
1.0 KiB
Bash
Executable File
#!/bin/bash
|
|
echo $header
|
|
ext=${file/*.}
|
|
range=10000
|
|
filename="/var/www/www.openmamba.org/$file"
|
|
filelines=`wc -l $filename | awk '{ print $1 }'`
|
|
filepages=`expr $filelines / $range + 1`
|
|
[ "$page" -a $page -gt 0 ] || page=1
|
|
from=`expr \( $page - 1 \) \* $range + 1`
|
|
to=`expr $from \+ $range - 1`
|
|
nextpage=`expr $page + 1`
|
|
prevpage=`expr $page - 1`
|
|
[ $from -ge $range ] && echo -n "<a href=\"showfile.html?file=$file&page=$prevpage\"><</a> " || echo -n "< "
|
|
idxsize=20
|
|
[ $page -gt $idxsize ] && idxfrom=`expr $page - $idxsize` || idxfrom=1
|
|
idxto=`expr $idxfrom + $idxsize \* 2`
|
|
[ $idxto -le $filepages ] || idxto=$filepages
|
|
[ $filepages -gt $idxsize ] && idxst=`expr $page - $idxsize` || idxst=1
|
|
for i in `seq $idxfrom $idxto`; do
|
|
if [ $i -eq $page ]; then
|
|
echo -n "$i "
|
|
else
|
|
echo -n "<a href=\"showfile.html?file=$file&page=$i\">$i</a> "
|
|
fi
|
|
done
|
|
[ $to -lt $filelines ] && echo -n "<a href=\"showfile.html?file=$file&page=$nextpage\">></a> " || echo -n "> "
|
|
echo
|
|
exit 0
|