Compare commits

..

69 Commits
master ... prod

Author SHA1 Message Date
Vincent Riquer
5eae26057f - 2022-04-28 15:29:36 +02:00
Vincent Riquer
469c4a660a Don't "prediuct" levelups in the past 2015-02-21 00:08:42 +01:00
Vincent Riquer
c99f70da58 OCR: ',' can sometimes be recognized ass a '_' 2015-02-21 00:07:42 +01:00
Vincent Riquer
3e976e643d fix OCR
* lighter convert pre transform
* make OCR more reliable
2015-02-21 00:06:01 +01:00
Vincent Riquer
408e11348d show correct medal 2015-02-14 04:21:07 +01:00
Vincent Riquer
5a14e0a099 Merge remote-tracking branch 'origin/master' into prod
* origin/master:
  Only show new medal requirements
  remove failed captures (avoids loop when it's the newest file)
  Add / Update copyright notices
  Use rrdcreate() everywhere
2015-02-10 14:50:19 +01:00
Vincent Riquer
3c6796cff1 Only show new medal requirements 2015-02-10 14:47:05 +01:00
Vincent Riquer
c2a57943f2 remove failed captures (avoids loop when it's the newest file) 2015-02-06 17:11:00 +01:00
Vincent Riquer
5ddb147317 Add / Update copyright notices 2015-02-06 17:10:02 +01:00
Vincent Riquer
78e49dd841 Use rrdcreate() everywhere 2015-02-06 16:35:45 +01:00
Vincent Riquer
daa4fb8a13 Merge remote-tracking branch 'origin/master' into prod
* origin/master:
  don't produce useless "Spent.." messages
  Fix RRD creation, quick & dirty
  fix unknown date handfling in "Overview"
  Stable image import
  prevision: only look 5y in the future (more precise)
  don't create lock for to early
  import from profile share
2015-02-06 14:48:37 +01:00
Vincent Riquer
8457708829 don't produce useless "Spent.." messages 2015-02-06 14:46:47 +01:00
Vincent Riquer
5e9a1cc52d Fix RRD creation, quick & dirty 2015-02-06 10:06:36 +01:00
Vincent Riquer
3312a78028 fix unknown date handfling in "Overview" 2015-02-06 09:51:18 +01:00
Vincent Riquer
b8e8b8395b Stable image import 2015-02-06 09:40:30 +01:00
Vincent Riquer
951c2a2bac prevision: only look 5y in the future (more precise) 2015-02-05 17:09:20 +01:00
Vincent Riquer
412fcfad37 don't create lock for to early 2015-02-04 20:24:23 +01:00
Vincent Riquer
c688a46f74 import from profile share 2015-02-04 20:06:09 +01:00
Vincent Riquer
a181718b86 Merge remote-tracking branch 'origin/master' into prod
* origin/master:
  up<medal> may not be set
  show correct medal
  Show the correct medal
2015-02-02 11:40:40 +01:00
Vincent Riquer
7482c81b31 up<medal> may not be set 2015-02-02 11:35:58 +01:00
Vincent Riquer
187bd18058 show correct medal 2015-02-02 11:29:12 +01:00
Vincent Riquer
1b67f9fd39 Show the correct medal 2015-02-02 11:21:25 +01:00
Vincent Riquer
3ee152c31e OCR PoC 2015-02-02 01:50:53 +01:00
Vincent Riquer
4b2e535678 Merge remote-tracking branch 'origin/master' into prod
* origin/master:
  remove now useless cache clear
2015-02-02 00:12:48 +01:00
Vincent Riquer
293c337f27 remove now useless cache clear 2015-02-02 00:11:50 +01:00
Vincent Riquer
da162f3690 Merge remote-tracking branch 'origin/master' into prod
* origin/master:
  304: take "settings" mtime into account
  import 0 as unknown
  Only show "real" DS
2015-02-01 23:51:48 +01:00
Vincent Riquer
648dfe8cdc 304: take "settings" mtime into account 2015-02-01 23:49:51 +01:00
Vincent Riquer
522f29e6d7 import 0 as unknown 2015-02-01 23:49:26 +01:00
Vincent Riquer
dc6ca9f073 Only show "real" DS 2015-02-01 23:48:39 +01:00
Vincent Riquer
1d04dec062 Merge remote-tracking branch 'origin/master' into prod
* origin/master:
  Implement 304 Not Modified
  use $rrdfile everywhere

Conflicts:
	import
	index
2015-02-01 22:28:52 +01:00
Vincent Riquer
b969488ac6 Implement 304 Not Modified 2015-02-01 22:19:48 +01:00
Vincent Riquer
a7c2b63dbe use $rrdfile everywhere 2015-02-01 22:17:10 +01:00
Vincent Riquer
4968e925fb Merge remote-tracking branch 'origin/master' into prod
* origin/master:
  add timing information
  fix vim accident #dontfeedthetroll
2015-02-01 17:12:49 +01:00
Vincent Riquer
38c9949dd7 add timing information 2015-02-01 04:30:51 +01:00
Vincent Riquer
3fc1a4c679 fix vim accident #dontfeedthetroll 2015-02-01 04:30:04 +01:00
Vincent Riquer
6c2f3bd95a Merge remote-tracking branch 'origin/master' into prod
* origin/master:
  add Translator
  better graph period chooser
2015-01-30 16:39:51 +01:00
Vincent Riquer
b3463f0ea5 Merge branch 'master' into prod
* master:
  SEE THE FUCKING FUTURE!
2015-01-30 16:37:32 +01:00
Vincent Riquer
050c3949fd add Translator 2015-01-30 16:36:03 +01:00
Vincent Riquer
a8e01a37ed better graph period chooser 2015-01-30 16:08:33 +01:00
Vincent Riquer
8964230c5b SEE THE FUCKING FUTURE! 2015-01-30 12:09:03 +01:00
Vincent Riquer
c94c990ad0 Merge remote-tracking branch 'origin/master' into prod
* origin/master:
  fix start/end conservation on import
  Add Recruiter

Conflicts:
	import
2015-01-22 16:19:20 +01:00
Vincent Riquer
338209ed31 fix start/end conservation on import 2015-01-22 16:12:29 +01:00
Vincent Riquer
d6115e9f73 Add Recruiter 2015-01-22 15:57:55 +01:00
Vincent Riquer
0318d46625 restore redirect 2014-12-26 15:40:02 +01:00
Vincent Riquer
8490562d9b Merge remote-tracking branch 'remotes/origin/master' into prod 2014-12-26 15:17:09 +01:00
Vincent Riquer
9269541e0a import more fail-proof 2014-12-26 15:12:45 +01:00
Vincent Riquer
c43877b8ad Merge remote-tracking branch 'remotes/origin/master' into prod 2014-11-26 11:38:58 +01:00
Vincent Riquer
7fc9376478 Merge remote-tracking branch 'remotes/origin/master' into prod 2014-11-26 11:29:49 +01:00
Vincent Riquer
b18133089f Merge remote-tracking branch 'origin/master' into prod
* origin/master:
  * medals: 0% is 100% for the lower medal
2014-07-07 16:19:42 +02:00
Vincent Riquer
c1aa8aad00 Merge remote-tracking branch 'origin/master' into prod
* origin/master:
  L9+ colors
2014-07-07 09:41:46 +02:00
Vincent Riquer
966244cb08 Merge remote-tracking branch 'origin/master' into prod
* origin/master:
  add.html: move"menu" div to end of document
2014-06-30 02:51:56 +02:00
Vincent Riquer
3d6f9bc4d0 Merge remote-tracking branch 'origin/master' into prod
* origin/master:
  graph legend:
  summary: link AP to AP graph
2014-06-30 02:21:20 +02:00
Vincent Riquer
fe7329e78f Merge remote-tracking branch 'origin/master' into prod
* origin/master:
  Show current level on all pages
2014-06-29 19:13:09 +02:00
Vincent Riquer
f7c44260b1 Merge remote-tracking branch 'origin/master' into prod
* origin/master:
  tick AP
2014-06-29 00:15:09 +02:00
Vincent Riquer
4b5c0af3a8 Merge remote-tracking branch 'origin/master' into prod
* origin/master:
  css validator
2014-06-24 00:59:29 +02:00
Vincent Riquer
0754138bc0 Merge remote-tracking branch 'origin/master' into prod
* origin/master:
  separate code from style
  hist: fix anchor placement
2014-06-24 00:44:20 +02:00
Vincent Riquer
07135f0c14 Merge remote-tracking branch 'origin/master' into prod
* origin/master:
  floating menu
2014-06-23 03:09:51 +02:00
Vincent Riquer
67b0823520 Merge remote-tracking branch 'origin/master' into prod
* origin/master:
  fancier
2014-06-21 03:40:02 +02:00
Vincent Riquer
1d9cba737e Merge remote-tracking branch 'origin/master' into prod
* origin/master:
  Ignore ingress.rrd
  Create RRD
  nicer table
2014-06-20 20:30:32 +02:00
Vincent Riquer
e4209d388b Merge remote-tracking branch 'origin/master' into prod
* origin/master:
  Licensing
2014-06-20 18:52:28 +02:00
Vincent Riquer
4082b7c753 restore CACHE_DIR settings 2014-06-20 17:23:46 +02:00
Vincent Riquer
849bf65548 Merge remote-tracking branch 'origin/master' into prod
* origin/master:
  fix timespan buttons
  centralize settings
  keep start / end settings
  nice menu
  fix medal links

Conflicts:
	add
2014-06-20 17:16:41 +02:00
Vincent Riquer
e436559928 Merge remote-tracking branch 'origin/master' into prod
* origin/master:
  Separate level overview from stat history
2014-06-20 12:46:48 +02:00
Vincent Riquer
f6e2c43832 Merge remote-tracking branch 'origin/master' into prod
* origin/master:
  show owned badges fix table width
2014-06-20 02:32:03 +02:00
Vincent Riquer
38e0b40eeb Merge remote-tracking branch 'origin/master' into prod
* origin/master:
  use images
2014-06-19 17:39:40 +02:00
Vincent Riquer
c27543c000 Merge remote-tracking branch 'origin/master' into prod
* origin/master:
  Badges targets: forgot medals above silver
2014-06-19 16:33:33 +02:00
Vincent Riquer
36649a6c1e Merge remote-tracking branch 'origin/master' into prod
* origin/master:
  show hints for medal targets
  Lighter color for below bronze stats
2014-06-19 16:10:17 +02:00
Vincent Riquer
85c5a09e57 Merge remote-tracking branch 'origin/master' into prod 2014-06-18 17:10:23 +02:00
Vincent Riquer
3ca3ab35a0 prod cache directory 2014-06-11 16:37:34 +02:00
21 changed files with 57572 additions and 453 deletions

16
add
View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# IngRRD (https://forge.riquer.fr/p/ingrrd/) # IngRRD (https://forge.riquer.fr/p/ingrrd/)
# Copyright (C) 2014 Vincent Riquer # Copyright (C) 2014-2015 Vincent Riquer
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as # it under the terms of the GNU Affero General Public License as
@ -64,13 +64,13 @@ do
ds="${ds//ds[/}" ds="${ds//ds[/}"
ds="${ds//]*/}" ds="${ds//]*/}"
datasets+=("$ds") datasets+=("$ds")
done < <(rrdtool info ingress.rrd |grep index) done < <(rrdtool info "$rrdfile" |grep index)
for ds in ${dsnames[@]} for ds in ${dsnames[@]}
do do
if [[ ! ${datasets[@]} =~ $ds ]] if [[ ! ${datasets[@]} =~ $ds ]]
then then
cp -f ingress.rrd ingress.rrd.bak_add_$ds cp -f "$rrdfile" "$rrdfile".bak_add_$ds
./dsaddtor.pl ingress.rrd $ds GAUGE $((48*60*60)) 0 NaN ./dsaddtor.pl "$rrdfile" $ds GAUGE $((48*60*60)) 0 NaN
fi fi
done done
data=N data=N
@ -82,10 +82,4 @@ do
done done
echo ${POST["innovator"]} > .innovator echo ${POST["innovator"]} > .innovator
rrdtool update ingress.rrd -t $template "$data" rrdtool update "$rrdfile" -t $template "$data"
if [ -n "$CACHE_DIR" ]
then
find "$CACHE_DIR" -type f -delete
echo $'\nCache cleared!'
fi

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# IngRRD (https://forge.riquer.fr/p/ingrrd/) # IngRRD (https://forge.riquer.fr/p/ingrrd/)
# Copyright (C) 2014 Vincent Riquer # Copyright (C) 2014-2015 Vincent Riquer
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as # it under the terms of the GNU Affero General Public License as
@ -22,13 +22,13 @@ for lib in lib/*
do do
source $lib source $lib
done done
import_images &
read_query_string read_query_string
send_headers <<-EOHead
content-type: text/xml
EOHead
cat <<-EOHTML cat <<-EOHTML
content-type: text/xml
Last-Modified: $(LC_ALL=C TZ=GMT date +'%a, %d %b %Y %X %Z')
Expires: $(LC_ALL=C TZ=GMT date +'%a, %d %b %Y %X %Z')
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
@ -42,45 +42,10 @@ Expires: $(LC_ALL=C TZ=GMT date +'%a, %d %b %Y %X %Z')
EOHTML EOHTML
if ! [ -w "$rrdfile" ] if ! [ -w "$rrdfile" ]
then then
rrdtool create ingress.rrd -s $((60*60)) \ rrdcreate || {
DS:AP:GAUGE:$((2*24*60*60)):0:NaN \
DS:Explorer:GAUGE:$((48*60*60)):0:NaN \
DS:Seer:GAUGE:$((48*60*60)):0:NaN \
DS:XM:GAUGE:$((48*60*60)):0:NaN \
DS:Hacker:GAUGE:$((48*60*60)):0:NaN \
DS:Builder:GAUGE:$((48*60*60)):0:NaN \
DS:Connector:GAUGE:$((48*60*60)):0:NaN \
DS:Mind_Controller:GAUGE:$((48*60*60)):0:NaN \
DS:MU:GAUGE:$((48*60*60)):0:NaN \
DS:Longest_Link:GAUGE:$((48*60*60)):0:NaN \
DS:Largest_Field:GAUGE:$((48*60*60)):0:NaN \
DS:Recharger:GAUGE:$((48*60*60)):0:NaN \
DS:Liberator:GAUGE:$((48*60*60)):0:NaN \
DS:Pioneer:GAUGE:$((48*60*60)):0:NaN \
DS:Purifier:GAUGE:$((48*60*60)):0:NaN \
DS:Neutralized:GAUGE:$((48*60*60)):0:NaN \
DS:Links_Destroyed:GAUGE:$((48*60*60)):0:NaN \
DS:Fields_Destroyed:GAUGE:$((48*60*60)):0:NaN \
DS:Walked:GAUGE:$((48*60*60)):0:NaN \
DS:Guardian:GAUGE:$((48*60*60)):0:NaN \
DS:Link_Maintained:GAUGE:$((48*60*60)):0:NaN \
DS:Link_Length_x_Days:GAUGE:$((48*60*60)):0:NaN \
DS:Field_Held:GAUGE:$((48*60*60)):0:NaN \
DS:Field_x_Days:GAUGE:$((48*60*60)):0:NaN \
DS:Mercenary:GAUGE:$((48*60*60)):0:NaN \
DS:Engineer:GAUGE:$((48*60*60)):0:NaN \
RRA:HWPREDICT:8760:8e-1:8e-1:$((24)) \
RRA:AVERAGE:99e-2:1:$((24*15)) \
RRA:MAX:99e-2:1:$((24*15)) \
RRA:AVERAGE:99e-2:4:$((24*180)) \
RRA:MAX:99e-2:4:$((24*180)) \
RRA:AVERAGE:99e-2:24:$(((4*365)+1)) \
RRA:MAX:99e-2:24:$(((4*365)+1)) \
RRA:AVERAGE:99e-2:$((24*30)):$(((32*365)+8)) \
RRA:MAX:99e-2:$((24*30)):$(((32*365)+8)) \
|| {
cat <<-EOHTML cat <<-EOHTML
<h1 style="color:red">Cannot create $rrdfile</h1> <h1 style="color:red">Cannot create $rrdfile</h1>
</div>
</body> </body>
</html> </html>
EOHTML EOHTML
@ -152,9 +117,10 @@ cat <<-EOHTML
<ul> <ul>
EOHTML EOHTML
for indice in ${!uinames[@]} for indice in ${dsnames[@]}
do do
echo "<li><input type=\"text\" name=\"${dsnames[indice]}\" value=\"${last["${dsnames[indice]}"]}\" /> ${uinames[indice]}</li>" [[ -z "${uinames[$indice]}" ]] && continue
echo "<li><input type=\"text\" name=\"$indice\" value=\"${last["$indice"]}\" /> ${uinames[$indice]}</li>"
done done
cat <<-EOHTML cat <<-EOHTML

125
import
View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# IngRRD (https://forge.riquer.fr/p/ingrrd/) # IngRRD (https://forge.riquer.fr/p/ingrrd/)
# Copyright (C) 2014 Vincent Riquer # Copyright (C) 2014-2015 Vincent Riquer
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as # it under the terms of the GNU Affero General Public License as
@ -24,43 +24,10 @@ do
done done
read_query_string read_query_string
template=AP:Explorer:Seer:XM:Walked:Builder:Connector:Mind_Controller:MU:Longest_Link:Largest_Field:Recharger:Liberator:Pioneer:Engineer:Purifier:Neutralized:Links_Destroyed:Fields_Destroyed:Guardian:Link_Maintained:Link_Length_x_Days:Field_Held:Field_x_Days:Mercenary:Hacker template=AP:Explorer:Seer:XM:Walked:Builder:Connector:Mind_Controller:MU:Longest_Link:Largest_Field:Recharger:Liberator:Pioneer:Engineer:Purifier:Neutralized:Links_Destroyed:Fields_Destroyed:Guardian:Link_Maintained:Link_Length_x_Days:Field_Held:Field_x_Days:Mercenary:Hacker:Translator:Hackaton:Recruiter
if [[ $REQUEST_METHOD == POST ]] if [[ $REQUEST_METHOD == POST ]]
then then
cat <<-EOHead
Content-type: text/plain
Last-Modified: $(LC_ALL=C TZ=GMT date +'%a, %d %b %Y %X %Z')
Expires: $(LC_ALL=C TZ=GMT date +'%a, %d %b %Y %X %Z')
EOHead
cat <<-EOHead >/dev/null
refresh: 0,url=/cgi/$webuser/?start=${POST["start"]}&end=${POST["end"]}
EOHead
if [[ $webuser == $AUTH_USER || $webuser == dev ]]
then
echo "Welcome agent $webuser"$'!\n\n'
else
echo 'Nice try!'
exit
fi
while read ds junk
do
ds="${ds//ds[/}"
ds="${ds//]*/}"
datasets+=("$ds")
done < <(rrdtool info ingress.rrd |grep index)
for ds in ${dsnames[@]}
do
if [[ ! ${datasets[@]} =~ $ds ]]
then
cp -f ingress.rrd ingress.rrd.bak_add_$ds
./dsaddtor.pl ingress.rrd $ds GAUGE $((48*60*60)) 0 NaN
fi
done
declare -A POST declare -A POST
exprdsname='^[[:upper:][:lower:]_]+$' exprdsname='^[[:upper:][:lower:]_]+$'
while read dsname value while read dsname value
@ -76,24 +43,51 @@ then
}" }"
POST["data"]="${POST["data"]//%3A/:}" POST["data"]="${POST["data"]//%3A/:}"
POST["data"]="${POST["data"]//+/ }" POST["data"]="${POST["data"]//+/ }"
echo "${POST["data"]}"
cat <<-EOHead
Content-type: text/plain
Last-Modified: $(LC_ALL=C TZ=GMT date +'%a, %d %b %Y %X %Z')
Expires: $(LC_ALL=C TZ=GMT date +'%a, %d %b %Y %X %Z')
EOHead
cat <<-EOHead
refresh: 0,url=/cgi/$webuser/?start=${POST["start"]}&end=${POST["end"]}
EOHead
echo
if [[ $webuser == $AUTH_USER || $webuser == dev ]]
then
echo "Welcome agent $webuser"$'!\n\n'
else
echo 'Nice try!'
exit
fi
while read ds junk
do
ds="${ds//ds[/}"
ds="${ds//]*/}"
datasets+=("$ds")
done < <(rrdtool info "$rrdfile" |grep index)
for ds in ${dsnames[@]}
do
if [[ ! ${datasets[@]} =~ $ds ]]
then
cp -f "$rrdfile" "$rrdfile".bak_add_$ds
./dsaddtor.pl "$rrdfile" $ds GAUGE $((48*60*60)) 0 NaN
fi
done
while read date hour data while read date hour data
do do
data=$(date -d "$date $hour" +%s):${data// /:} data=$(date -d "$date $hour" +%s):${data// /:}
rrdtool update ingress.rrd -t $template "$data" 2>&1 rrdtool update "$rrdfile" -t $template "${data//:0/:U}" 2>&1
done <<<"${POST["data"]}" done <<<"${POST["data"]}"
if [ -n "$CACHE_DIR" ]
then
find "$CACHE_DIR" -type f -delete
echo $'\nCache cleared!'
fi
else else
cat <<-EOHTML import_images &
send_headers <<-EOHead
content-type: text/xml content-type: text/xml
Last-Modified: $(LC_ALL=C TZ=GMT date +'%a, %d %b %Y %X %Z') EOHead
Expires: $(LC_ALL=C TZ=GMT date +'%a, %d %b %Y %X %Z')
cat <<-EOHTML
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
@ -107,43 +101,7 @@ else
EOHTML EOHTML
if ! [ -w "$rrdfile" ] if ! [ -w "$rrdfile" ]
then then
rrdtool create ingress.rrd -s $((60*60)) \ rrdcreate || {
DS:AP:GAUGE:$((2*24*60*60)):0:NaN \
DS:Explorer:GAUGE:$((48*60*60)):0:NaN \
DS:Seer:GAUGE:$((48*60*60)):0:NaN \
DS:XM:GAUGE:$((48*60*60)):0:NaN \
DS:Hacker:GAUGE:$((48*60*60)):0:NaN \
DS:Builder:GAUGE:$((48*60*60)):0:NaN \
DS:Connector:GAUGE:$((48*60*60)):0:NaN \
DS:Mind_Controller:GAUGE:$((48*60*60)):0:NaN \
DS:MU:GAUGE:$((48*60*60)):0:NaN \
DS:Longest_Link:GAUGE:$((48*60*60)):0:NaN \
DS:Largest_Field:GAUGE:$((48*60*60)):0:NaN \
DS:Recharger:GAUGE:$((48*60*60)):0:NaN \
DS:Liberator:GAUGE:$((48*60*60)):0:NaN \
DS:Pioneer:GAUGE:$((48*60*60)):0:NaN \
DS:Purifier:GAUGE:$((48*60*60)):0:NaN \
DS:Neutralized:GAUGE:$((48*60*60)):0:NaN \
DS:Links_Destroyed:GAUGE:$((48*60*60)):0:NaN \
DS:Fields_Destroyed:GAUGE:$((48*60*60)):0:NaN \
DS:Walked:GAUGE:$((48*60*60)):0:NaN \
DS:Guardian:GAUGE:$((48*60*60)):0:NaN \
DS:Link_Maintained:GAUGE:$((48*60*60)):0:NaN \
DS:Link_Length_x_Days:GAUGE:$((48*60*60)):0:NaN \
DS:Field_Held:GAUGE:$((48*60*60)):0:NaN \
DS:Field_x_Days:GAUGE:$((48*60*60)):0:NaN \
DS:Mercenary:GAUGE:$((48*60*60)):0:NaN \
DS:Engineer:GAUGE:$((48*60*60)):0:NaN \
RRA:HWPREDICT:8760:8e-1:8e-1:$((24)) \
RRA:AVERAGE:99e-2:1:$((24*15)) \
RRA:MAX:99e-2:1:$((24*15)) \
RRA:AVERAGE:99e-2:4:$((24*180)) \
RRA:MAX:99e-2:4:$((24*180)) \
RRA:AVERAGE:99e-2:24:$(((4*365)+1)) \
RRA:MAX:99e-2:24:$(((4*365)+1)) \
RRA:AVERAGE:99e-2:$((24*30)):$(((32*365)+8)) \
RRA:MAX:99e-2:$((24*30)):$(((32*365)+8)) \
|| {
cat <<-EOHTML cat <<-EOHTML
<h1 style="color:red">Cannot create $rrdfile</h1> <h1 style="color:red">Cannot create $rrdfile</h1>
</body> </body>
@ -160,6 +118,7 @@ else
<p>Import data from e.g. https://www.agent-stats.com/ <br/> <p>Import data from e.g. https://www.agent-stats.com/ <br/>
<small>Expected format: <tt>YYYY-MM-DD hh:mm:ss <small>Expected format: <tt>YYYY-MM-DD hh:mm:ss
${template[@]//:/ }</tt></small></p> ${template[@]//:/ }</tt></small></p>
<p>Latest data: $(date +"%Y-%m-%d %H:%M:%S" -d @${last[time]%:})</p>
<form method="post" action="import"> <form method="post" action="import">
<input type="hidden" name="start" value="$start" /> <input type="hidden" name="start" value="$start" />
<input type="hidden" name="end" value="$end" /> <input type="hidden" name="end" value="$end" />

430
index
View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# IngRRD (https://forge.riquer.fr/p/ingrrd/) # IngRRD (https://forge.riquer.fr/p/ingrrd/)
# Copyright (C) 2014 Vincent Riquer # Copyright (C) 2014-2015 Vincent Riquer
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as # it under the terms of the GNU Affero General Public License as
@ -22,26 +22,25 @@ for lib in lib/*
do do
source $lib source $lib
done done
if [ ! -w "$rrdfile" ]
then
cat <<-EOHead
Content-type: text/plain
Last-Modified: $(LC_ALL=C TZ=GMT date +'%a, %d %b %Y %X %Z')
Expires: $(LC_ALL=C TZ=GMT date +'%a, %d %b %Y %X %Z')
refresh: 0,url=/cgi/$webuser/add.html
EOHead
exit
fi
read_query_string read_query_string
(( start >= end)) && (( end = start + 604800 )) (( start >= end)) && (( end = start + 604800 ))
if [ -z "$graph" ] if [ -z "$graph" ]
then then
import_images &
refresh=300
[[ -r .importing ]] && refresh=5
send_headers $(( refresh - 1 )) <<-EOHead
content-type: application/xhtml+xml
refresh: $refresh
EOHead
readlast readlast
medals medals
get_current_level get_current_level
readold "${last[time]}-$prevperiod"
get_next_level
if (( show_all )) if (( show_all ))
then then
title="IngRRD - $webuser [L$curlevel] - History &amp; Trend: All stats" title="IngRRD - $webuser [L$curlevel] - History &amp; Trend: All stats"
@ -52,15 +51,6 @@ then
title="IngRRD - $webuser [L$curlevel] - Overview" title="IngRRD - $webuser [L$curlevel] - Overview"
fi fi
cat <<-EOHTML cat <<-EOHTML
content-type: application/xhtml+xml
Last-Modified: $(
LC_ALL=C TZ=GMT date +'%a, %d %b %Y %X %Z' \
-d @$(rrdtool last ingress.rrd)
)
Expires: $(LC_ALL=C TZ=GMT date +'%a, %d %b %Y %X %Z' -d '1 hour')
Cache-Control: max-age=0, must-revalidate
refresh: 600
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
@ -70,6 +60,12 @@ then
<link rel="stylesheet" type="text/css" href="/ingrrd.css" /> <link rel="stylesheet" type="text/css" href="/ingrrd.css" />
</head> </head>
<body> <body>
<div style="font-size:10px; color:#606060; text-align:right; position:absolute; top:12px; right:0px;">
EOHTML
times
date '+%Y-%m-%d %H:%M:%S'
cat <<-EOHTML
</div>
<div style="width:$(( graph_width + 97 ))px" class="container"> <div style="width:$(( graph_width + 97 ))px" class="container">
EOHTML EOHTML
@ -116,6 +112,9 @@ then
</table> </table>
EOHTML EOHTML
show_current_level show_current_level
[[ -r .importing ]] && cat <<-EOHTML
<div class="updating">Importing $(<.importing)</div>
EOHTML
cat <<-EOHTML cat <<-EOHTML
</div> </div>
<div class="main"> <div class="main">
@ -132,150 +131,217 @@ then
<th class="badge">Black</th> <th class="badge">Black</th>
</tr> </tr>
EOHTML EOHTML
for level in {1..16} for level in {1..16}
do do
prevtimestamp=$maxtimestamp
never=0
maxtimestamp=0
tableline=()
if (( last["AP"] >= lvl[level] ))
then
tableline+=( '<td class="AP" style="background:lightgreen">'
$(printf "%'li" ${lvl[level]})
'</td>' )
else
#FIXME
readable=$(printf "%'li" ${lvl[level]})
tableline+=( '<td class="AP" style="background:lightgrey">'"${readable// /&nbsp;}" )
readable=$(printf "%'li" $(( last["AP"] - lvl[level] )))
tableline+=( "<br />(<span class=\"missing\">${readable// /&nbsp;}</span>)" )
if (( timestamp ))
then
tableline+=( "<br />$(date +%Y-%m-%d -d @${nextlevels[level]})</td>" )
(( nextlevels[level] > maxtimestamp )) \
&& maxtimestamp=${nextlevels[level]}
else
tableline+=( "<br />(maybe some day)</td>" )
never=1
fi
fi
if (( silvercount >= lvlsilver[level] ))
then
tableline+=( '<td class="badge" style="background:lightgreen">'${lvlsilver[level]}'</td>' )
else
tableline+=( "<td class=\"badge\" style=\"background:lightgrey\">${lvlsilver[level]} (<span class=\"missing\">$(( silvercount - lvlsilver[level] ))</span>)<br />" )
count=0
for timestamp in ${!nextsilver[@]}
do
if (( timestamp ))
then
thisdate=$(date +%Y-%m-%d -d @$timestamp)
(( timestamp > maxtimestamp )) \
&& maxtimestamp=$timestamp
for stat in ${nextsilver[timestamp]}
do
if ! (( shown["$stat silver"] ))
then
tableline+=( "$(print_medal $timestamp $stat ${upsilver[$stat]:-0} silver)" )
tableline+=( '<br />' )
shown["$stat silver"]=1
fi
(( ++count == lvlsilver[level] - silvercount )) && break 2
done
fi
done
for stat in ${nextsilver[0]}
do
(( count >= lvlsilver[level] - silvercount )) && break 1
(( count < lvlsilver[level] - silvercount )) && never=1
if ! (( shown["$stat silver"] ))
then
tableline+=( "$(print_medal $timestamp $stat ${upsilver[$stat]:-0} silver)" )
tableline+=( '<br />' )
shown["$stat silver"]=1
fi
(( count++ ))
done
tableline+=( '</td>' )
fi
if (( goldcount >= lvlgold[level] ))
then
tableline+=( '<td class="badge" style="background:lightgreen">'${lvlgold[level]}'</td>' )
else
tableline+=( "<td class=\"badge\" style=\"background:lightgrey\">${lvlgold[level]} (<span class=\"missing\">$(( goldcount - lvlgold[level] ))</span>)<br />" )
count=0
for timestamp in ${!nextgold[@]}
do
if (( timestamp ))
then
thisdate=$(date +%Y-%m-%d -d @$timestamp)
(( timestamp > maxtimestamp )) \
&& maxtimestamp=$timestamp
for stat in ${nextgold[timestamp]}
do
if ! (( shown["$stat gold"] ))
then
tableline+=( "$(print_medal $timestamp $stat ${upgold[$stat]:-0} gold)" )
tableline+=( '<br />' )
shown["$stat gold"]=1
fi
(( ++count == lvlgold[level] - goldcount )) && break 2
done
fi
done
for stat in ${nextgold[0]}
do
(( count >= lvlgold[level] - goldcount )) && break 1
(( count < lvlgold[level] - goldcount )) && never=1
if ! (( shown["$stat gold"] ))
then
tableline+=( "$(print_medal $timestamp $stat ${upgold[$stat]:-0} gold)" )
tableline+=( '<br />' )
shown["$stat gold"]=1
fi
(( count++ ))
done
tableline+=( '</td>' )
fi
if (( platinumcount >= lvlplatinum[level] ))
then
tableline+=( '<td class="badge" style="background:lightgreen">'${lvlplatinum[level]}'</td>' )
else
tableline+=( "<td class=\"badge\" style=\"background:lightgrey\">${lvlplatinum[level]} (<span class=\"missing\">$(( platinumcount - lvlplatinum[level] ))</span>)<br />" )
count=0
for timestamp in ${!nextplatinum[@]}
do
if (( timestamp ))
then
thisdate=$(date +%Y-%m-%d -d @$timestamp)
(( timestamp > maxtimestamp )) \
&& maxtimestamp=$timestamp
for stat in ${nextplatinum[timestamp]}
do
if ! (( shown["$stat platinum"] ))
then
tableline+=( "$(print_medal $timestamp $stat ${upplatinum[$stat]:-0} platinum)" )
tableline+=( '<br />' )
shown["$stat platinum"]=1
fi
(( ++count == lvlplatinum[level] - platinumcount )) && break 2
done
fi
done
for stat in ${nextplatinum[0]}
do
(( count >= lvlplatinum[level] - platinumcount )) && break 1
(( count < lvlplatinum[level] - platinumcount )) && never=1
if ! (( shown["$stat platinum"] ))
then
tableline+=( "$(print_medal $timestamp $stat ${upplatinum[$stat]:-0} platinum)" )
tableline+=( '<br />' )
shown["$stat platinum"]=1
fi
(( count++ ))
done
tableline+=( '</td>' )
fi
if (( blackcount >= lvlblack[level] ))
then
tableline+=( '<td class="badge" style="background:lightgreen">'${lvlblack[level]}'</td>' )
else
tableline+=( "<td class=\"badge\" style=\"background:lightgrey\">${lvlblack[level]} (<span class=\"missing\">$(( blackcount - lvlblack[level] ))</span>)<br />" )
count=0
for timestamp in ${!nextblack[@]}
do
if (( timestamp ))
then
thisdate=$(date +%Y-%m-%d -d @$timestamp)
(( timestamp > maxtimestamp )) \
&& maxtimestamp=$timestamp
for stat in ${nextblack[timestamp]}
do
if ! (( shown["$stat black"] ))
then
tableline+=( "$(print_medal $timestamp $stat ${upblack[$stat]:-0} black)" )
tableline+=( '<br />' )
shown["$stat black"]=1
fi
(( ++count == lvlblack[level] - blackcount )) && break 2
done
fi
done
for stat in ${nextblack[0]}
do
(( count >= lvlblack[level] - blackcount )) && break 1
(( count < lvlblack[level] - blackcount )) && never=1
if ! (( shown["$stat black"] ))
then
tableline+=( "$(print_medal $timestamp $stat ${upblack[$stat]:-0} black)" )
tableline+=( '<br />' )
shown["$stat black"]=1
fi
(( count++ ))
done
tableline+=( '</td>' )
fi
if (( level <= curlevel )) if (( level <= curlevel ))
then then
echo "<tr class=\"curlevel\"><th class=\"level\">$level</th>" echo "<tr class=\"curlevel\"><th class=\"level\">$level</th>"
else else
echo "<tr class=\"nextlevel\"><th class=\"level\">$level</th>"
fi
if (( last["AP"] >= lvl[level] ))
then
echo '<td class="AP" style="background:lightgreen">'
printf "%'li" ${lvl[level]}
echo '</td>'
else
readable=$(printf "%'li" ${lvl[level]})
echo '<td class="AP" style="background:lightgrey">'"${readable// /&nbsp;}"
readable=$(printf "%'li" $(( last["AP"] - lvl[level] )))
echo "<br />(<span class=\"missing\">${readable// /&nbsp;}</span>)</td>"
fi
if (( silvercount >= lvlsilver[level] ))
then
echo '<td class="badge" style="background:lightgreen">'${lvlsilver[level]}'</td>'
else
echo "<td class=\"badge\" style=\"background:lightgrey\">${lvlsilver[level]} (<span class=\"missing\">$(( silvercount - lvlsilver[level] ))</span>)<br />"
count=0
for id in {100..0}
do
[ -z "${upsilver[id]}" ] && continue
(( greenlevel = id * 255 / 100 ))
(( redlevel = 255 - greenlevel ))
for stat in ${upsilver[id]}
do
img=${stat,,}
cat <<-EOHTML cat <<-EOHTML
<a <tr class="nextlevel">
class="badge" <th class="level">$level</th>
style="background:#$(printf %02x%02x $redlevel $greenlevel )00"
href="?hist&amp;start=$start&amp;end=$end#$stat">
<img
class="badge"
src="/${img//_/-}-silver.png"
title="$stat $id%"
alt="$stat silver" />
</a>
EOHTML EOHTML
(( count++ == lvlsilver[level] - silvercount )) && break 2
done
done
echo '</td>'
fi fi
if (( goldcount >= lvlgold[level] )) echo "${tableline[@]}"
if (( level > curlevel ))
then
(( maxtimestamp < prevtimestamp )) \
&& maxtimestamp=$prevtimestamp
if (( maxtimestamp ))
then then
echo '<td class="badge" style="background:lightgreen">'${lvlgold[level]}'</td>'
else
echo "<td class=\"badge\" style=\"background:lightgrey\">${lvlgold[level]} (<span class=\"missing\">$(( goldcount - lvlgold[level] ))</span>)<br />"
count=0
for id in {100..0}
do
[ -z "${upgold[id]}" ] && continue
(( greenlevel = id * 255 / 100 ))
(( redlevel = 255 - greenlevel ))
for stat in ${upgold[id]}
do
img=${stat,,}
cat <<-EOHTML cat <<-EOHTML
<a <td class="date">$(date +%Y-%m-%d -d @$maxtimestamp)</td>
class="badge" EOHTML
style="background:#$(printf %02x%02x $redlevel $greenlevel )00" else
href="?hist&amp;start=$start&amp;end=$end#$stat"> cat <<-EOHTML
<img <td class="date">In more than 5 years</td>
class="badge"
src="/${img//_/-}-gold.png"
title="$stat $id%"
alt="$stat gold" />
</a>
EOHTML EOHTML
(( count++ == lvlgold[level] - goldcount )) && break 2
done
done
echo '</td>'
fi fi
if (( platinumcount >= lvlplatinum[level] ))
then
echo '<td class="badge" style="background:lightgreen">'${lvlplatinum[level]}'</td>'
else
echo "<td class=\"badge\" style=\"background:lightgrey\">${lvlplatinum[level]} (<span class=\"missing\">$(( platinumcount - lvlplatinum[level] ))</span>)<br />"
count=0
for id in {100..0}
do
[ -z "${upplatinum[id]}" ] && continue
(( greenlevel = id * 255 / 100 ))
(( redlevel = 255 - greenlevel ))
for stat in ${upplatinum[id]}
do
img=${stat,,}
cat <<-EOHTML
<a
class="badge"
style="background:#$(printf %02x%02x $redlevel $greenlevel )00"
href="?hist&amp;start=$start&amp;end=$end#$stat">
<img
class="badge"
src="/${img//_/-}-platinum.png"
title="$stat $id%"
alt="$stat platinum" />
</a>
EOHTML
(( count++ == lvlplatinum[level] - platinumcount )) && break 2
done
done
echo '</td>'
fi
if (( blackcount >= lvlblack[level] ))
then
echo '<td class="badge" style="background:lightgreen">'${lvlblack[level]}'</td>'
else
echo "<td class=\"badge\" style=\"background:lightgrey\">${lvlblack[level]} (<span class=\"missing\">$(( blackcount - lvlblack[level] ))</span>)<br />"
count=0
for id in {100..0}
do
[ -z "${upblack[id]}" ] && continue
(( greenlevel = id * 255 / 100 ))
(( redlevel = 255 - greenlevel ))
for stat in ${upblack[id]}
do
img=${stat,,}
cat <<-EOHTML
<a
class="badge"
style="background:#$(printf %02x%02x $redlevel $greenlevel )00"
href="?hist&amp;start=$start&amp;end=$end#$stat">
<img
class="badge"
src="/${img//_/-}-black.png"
title="$stat $id%"
alt="$stat black" />
</a>
EOHTML
(( count++ == lvlblack[level] - blackcount )) && break 2
done
done
echo '</td>'
fi fi
echo '</tr>' echo '</tr>'
prevtimestamp=$maxtimestamp
done done
cat <<-EOHTML cat <<-EOHTML
</table> </table>
@ -341,21 +407,35 @@ then
<table style="width:$(( graph_width + 97 ))px"> <table style="width:$(( graph_width + 97 ))px">
<tr> <tr>
<td> <td>
<a href="?hist&amp;start=$(( start - 604800 ))&amp;end=$end">&lt;&lt;</a> <a href="?hist&amp;start=$(rrdtool first "$rrdfile")&amp;end=$end">First</a>
<a href="?hist&amp;start=$(( start - 86400 ))&amp;end=$end">&lt;</a> <a href="?hist&amp;start=$(( start - 365 * 86400 ))&amp;end=$end">-Y</a>
<a href="?hist&amp;start=$default_start&amp;end=$end">R</a> <a href="?hist&amp;start=$(( start - 30 * 86400 ))&amp;end=$end">-M</a>
<a href="?hist&amp;start=$(( start + 86400 ))&amp;end=$end">&gt;</a> <a href="?hist&amp;start=$(( start - 604800 ))&amp;end=$end">-W</a>
<a href="?hist&amp;start=$(( start + 604800 ))&amp;end=$end">&gt;&gt;</a> <a href="?hist&amp;start=$(( start - 86400 ))&amp;end=$end">-D</a>
<a href="?hist&amp;start=$now&amp;end=$end">Now</a>
<a href="?hist&amp;start=$(( start + 86400 ))&amp;end=$end">+D</a>
<a href="?hist&amp;start=$(( start + 604800 ))&amp;end=$end">+W</a>
<a href="?hist&amp;start=$(( start + 30 * 86400 ))&amp;end=$end">+M</a>
<a href="?hist&amp;start=$(( start + 365 * 86400 ))&amp;end=$end">+Y</a>
</td> </td>
<td align="right"> <td align="right">
<a href="?hist&amp;start=$start&amp;end=$(( end - 604800 ))">&lt;&lt;</a> <a href="?hist&amp;start=$start&amp;end=$(( end - 365 * 86400 ))">-Y</a>
<a href="?hist&amp;start=$start&amp;end=$(( end - 86400 ))">&lt;</a> <a href="?hist&amp;start=$start&amp;end=$(( end - 30 * 86400 ))">-M</a>
<a href="?hist&amp;start=$start&amp;end=$default_end">R</a> <a href="?hist&amp;start=$start&amp;end=$(( end - 604800 ))">-W</a>
<a href="?hist&amp;start=$start&amp;end=$(( end + 86400 ))">&gt;</a> <a href="?hist&amp;start=$start&amp;end=$(( end - 86400 ))">-D</a>
<a href="?hist&amp;start=$start&amp;end=$(( end + 604800 ))">&gt;&gt;</a> <a href="?hist&amp;start=$start&amp;end=$now">Now</a>
<a href="?hist&amp;start=$start&amp;end=$(( end + 86400 ))">+D</a>
<a href="?hist&amp;start=$start&amp;end=$(( end + 604800 ))">+W</a>
<a href="?hist&amp;start=$start&amp;end=$(( end + 30 * 86400 ))">+M</a>
<a href="?hist&amp;start=$start&amp;end=$(( end + 365 * 86400 ))">+Y</a>
</td> </td>
</tr> </tr>
</table> </table>
EOHTML
[[ -r .importing ]] && cat <<-EOHTML
<div class="updating">Importing $(<.importing)</div>
EOHTML
cat <<-EOHTML
</div> </div>
<div class="maingraph"> <div class="maingraph">
EOHTML EOHTML
@ -374,6 +454,7 @@ then
for stat in "${stats[@]}" for stat in "${stats[@]}"
do do
[[ -z "${uinames[$stat]}" ]] && continue
if [[ $stat == AP ]] || (( bronze["$stat"] )) if [[ $stat == AP ]] || (( bronze["$stat"] ))
then then
height=169 height=169
@ -415,7 +496,7 @@ then
</a> </a>
</td> </td>
<td style="text-align:center"> <td style="text-align:center">
Generated by <a href="https://forge.riquer.fr/p/ingrrd/">IngRRD</a> &copy; 2014 Vincent Riquer Generated by <a href="https://forge.riquer.fr/p/ingrrd/">IngRRD</a> &copy; 2014-2015 Vincent Riquer
</td> </td>
<td style="text-align:right; width:180px"> <td style="text-align:right; width:180px">
<a href="http://www.fsf.org/licensing/licenses/agpl-3.0.html"> <a href="http://www.fsf.org/licensing/licenses/agpl-3.0.html">
@ -426,21 +507,20 @@ then
</table> </table>
</div> </div>
</div> </div>
<div style="font-size:10px; color:#606060; text-align:right; position:absolute; top:24px; right:0px;">
EOHTML
times
date '+%Y-%m-%d %H:%M:%S'
cat <<-EOHTML
</div>
</body></html> </body></html>
EOHTML EOHTML
else else
now=$(date +%s) send_headers <<-EOHead
cat <<-EOHEAD
content-type: image/png content-type: image/png
Last-Modified: $( EOHead
LC_ALL=C TZ=GMT date +'%a, %d %b %Y %X %Z' \
-d @$(rrdtool last ingress.rrd)
)
Expires: $(LC_ALL=C TZ=GMT date +'%a, %d %b %Y %X %Z' -d '1 hour')
Cache-Control: max-age=0, must-revalidate
EOHEAD
now=$(date +%s)
if [[ $graph == AP ]] if [[ $graph == AP ]]
then then
thresholds=( thresholds=(
@ -580,16 +660,14 @@ else
next=('COMMENT:\n') next=('COMMENT:\n')
fi fi
(( start > -1209600 )) && datastart=-1209600 (( start - now > -1209600 )) && datastart=-1209600
(( end < 157680001 )) && dataend="+157680001" (( end - now < 157680001 )) && dataend="+157680001"
(( start > 0 )) && start="+$start"
(( end > 0 )) && end="+$end"
(( datastart > 0 )) && datastart="+$datastart" (( datastart > 0 )) && datastart="+$datastart"
rrdtool graph - \ rrdtool graph - \
-a PNG \ -a PNG \
-w $graph_width \ -w $graph_width \
-v $graph \ -v "${uinames[$graph]}" \
-s $start -e $end \ -s $start -e $end \
DEF:data=$rrdfile:$graph:AVERAGE:step=3600${datastart+:start=$datastart}${dataend+:end=$dataend} \ DEF:data=$rrdfile:$graph:AVERAGE:step=3600${datastart+:start=$datastart}${dataend+:end=$dataend} \
DEF:fail=$rrdfile:$graph:FAILURES \ DEF:fail=$rrdfile:$graph:FAILURES \

56169
ingress.xml Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
/* /*
* IngRRD (https://forge.riquer.fr/p/ingrrd/) * IngRRD (https://forge.riquer.fr/p/ingrrd/)
* Copyright (C) 2014 Vincent Riquer * Copyright (C) 2014-2015 Vincent Riquer
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as * it under the terms of the GNU Affero General Public License as
@ -59,6 +59,13 @@ td.submenu-inv {
background: #444; background: #444;
color: white color: white
} }
div.updating {
position: relative;
background: orange;
width: 100%;
text-align: center;
font-size: larger;
}
div.main { div.main {
position: absolute; position: absolute;
@ -113,7 +120,7 @@ th.AP,td.AP {
} }
th.badge,td.badge { th.badge,td.badge {
width: 170px; /* width: 170px;*/
} }
a.badge { a.badge {

View File

@ -1,5 +1,21 @@
#!/bin/bash #!/bin/bash
# IngRRD (https://forge.riquer.fr/p/ingrrd/)
# Copyright (C) 2014-2015 Vincent Riquer
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
get_current_level() { get_current_level() {
for level in {1..16} for level in {1..16}
do do

127
lib/get_next_level Normal file
View File

@ -0,0 +1,127 @@
#!/bin/bash
# IngRRD (https://forge.riquer.fr/p/ingrrd/)
# Copyright (C) 2014-2015 Vincent Riquer
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
get_next_level() {
local level
local now=$(date +%s)
next=()
for (( level = curlevel + 1; level <= 16; level++))
do
if (( lvl[level] > last["AP"] ))
then
next+=(
CDEF:nextcross$level=pred,${lvl[level]},GE,pred,UNKN,IF
VDEF:nexttime$level=nextcross$level,FIRST
"PRINT:nexttime$level:$level %s:strftime"
)
fi
done
{
read
while read level timestamp
do
(( timestamp && timestamp < now )) && timestamp=$now
nextlevels[level]=$timestamp
done
} < <(
rrdtool graph /dev/null -s -$prevperiod -e +5y \
DEF:data=$rrdfile:AP:AVERAGE:step=3600 \
VDEF:intercept=data,LSLINT \
VDEF:growth=data,LSLSLOPE \
CDEF:trend=data,POP,COUNT,growth,*,intercept,+ \
CDEF:pred=TIME,NOW,GE,trend,UNKN,IF \
"${next[@]}"
)
for stat in ${medals[@]}
do
next=()
if ! (( hasbronze[$stat] ))
then
next+=(
CDEF:nextcrossbronze=pred,${bronze[$stat]},GE,pred,UNKN,IF
VDEF:nexttimebronze=nextcrossbronze,FIRST
"PRINT:nexttimebronze:bronze %s:strftime"
)
fi
if ! (( hassilver[$stat] ))
then
next+=(
CDEF:nextcrosssilver=pred,${silver[$stat]},GE,pred,UNKN,IF
VDEF:nexttimesilver=nextcrosssilver,FIRST
"PRINT:nexttimesilver:silver %s:strftime"
)
fi
if ! (( hasgold[$stat] ))
then
next+=(
CDEF:nextcrossgold=pred,${gold[$stat]},GE,pred,UNKN,IF
VDEF:nexttimegold=nextcrossgold,FIRST
"PRINT:nexttimegold:gold %s:strftime"
)
fi
if ! (( hasplatinum[$stat] ))
then
next+=(
CDEF:nextcrossplatinum=pred,${platinum[$stat]},GE,pred,UNKN,IF
VDEF:nexttimeplatinum=nextcrossplatinum,FIRST
"PRINT:nexttimeplatinum:platinum %s:strftime"
)
fi
if ! (( hasblack[$stat] ))
then
next+=(
CDEF:nextcrossblack=pred,${black[$stat]},GE,pred,UNKN,IF
VDEF:nexttimeblack=nextcrossblack,FIRST
"PRINT:nexttimeblack:black %s:strftime"
)
fi
{
read
while read matter timestamp
do
(( timestamp && timestamp < now )) && timestamp=$now
case $matter in
bronze)
nextbronze[timestamp]+="$stat "
;;
silver)
nextsilver[timestamp]+="$stat "
;;
gold)
nextgold[timestamp]+="$stat "
;;
platinum)
nextplatinum[timestamp]+="$stat "
;;
black)
nextblack[timestamp]+="$stat "
;;
esac
done
} < <(
rrdtool graph /dev/null -s -$prevperiod -e +5y \
DEF:data=$rrdfile:$stat:AVERAGE:step=600 \
VDEF:intercept=data,LSLINT \
VDEF:growth=data,LSLSLOPE \
CDEF:trend=data,POP,COUNT,growth,*,intercept,+ \
CDEF:pred=TIME,NOW,GE,trend,UNKN,IF \
"${next[@]}"
)
done
}

View File

@ -1,11 +1,39 @@
#!/bin/bash #!/bin/bash
# IngRRD (https://forge.riquer.fr/p/ingrrd/)
# Copyright (C) 2014-2015 Vincent Riquer
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
declare -A \ declare -A \
last \ last \
nosilver \ nosilver \
nogold \ nogold \
noplatinum \ noplatinum \
noblack \ noblack \
upbronze \
upsilver \
upgold \
upplatinum \
upblack \
hasbronze \
hassilver \
hasgold \
hasplatinum \
hasblack \
first \
shown \
declare -a \ declare -a \
bronzes \ bronzes \
@ -13,11 +41,11 @@ declare -a \
golds \ golds \
platinums \ platinums \
blacks \ blacks \
upbronze \ nextbronze \
upsilver \ nextsilver \
upgold \ nextgold \
upplatinum \ nextplatinum \
upblack \ nextblack \
declare -i \ declare -i \
bronzecount \ bronzecount \
@ -33,6 +61,7 @@ declare \
graph \ graph \
start \ start \
end \ end \
prevperiod \
want_ds=( want_ds=(
AP AP

238
lib/image Executable file
View File

@ -0,0 +1,238 @@
#!/bin/bash
# IngRRD (https://forge.riquer.fr/p/ingrrd/)
# Copyright (C) 2015 Vincent Riquer
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
image() {
exec 2>&1
local timestamp=$2
declare -A values
tmpfile=$(mktemp --suffix=.tiff)
transform='-resize 350%x200% -contrast -channel green -threshold 50%'
if (( debug_import >= 3 ))
then
readarray -t tactout < <(convert $transform "$1" -format tiff - | tee "${1%.png}.tiff" | tesseract -l eng -psm 4 stdin stdout)
else
readarray -t tactout < <(convert $transform "$1" -format tiff - | tesseract -l eng -psm 4 stdin stdout)
fi
if ((debug_import >=2 ))
then
for index in ${!tactout[@]}
do
echo "${tactout[index]}"
done > "${1%.png}.txt"
fi
rm "$tmpfile"
for line in "${tactout[@]}"
do
case "$line" in
'Error, please try again.')
# Ingress failed when generating image, ignore file.
echo $'\tFailed capture, file removed.'
rm "$1"
return 3
;;
#14,522,411 AP 144mm AP
*' AP'*)
read value junk <<<"$line"
value=${value//_/}
values[AP]=${value//,/}
;;
#Unique Portals Visited 718
'Unique Portals Visited'*)
value="${line#Unique Portals Visited }"
value=${value//_/}
read values[Explorer] junk <<<"${value//,}"
;;
#Portals Discovered 9
'Portals Discovered'*)
value="${line#Portals Discovered }"
value=${value//_/}
read values[Seer] junk <<<"${value//,/}"
;;
#XM Collected 130,908,527 XM
'XM Collected'*)
value="${line#XM Collected}"
value=${value//_/}
read values[XM] junk <<<"${value//,/}"
;;
#Distance Walked 1,785 km
'Distance Walked'*)
value="${line#Distance Walked }"
value=${value//_/}
read values[Walked] junk <<<"${value//,/}"
;;
#Resonators Deployed 24,451
'Resonators Deployed'*)
value="${line#Resonators Deployed }"
value=${value//_/}
read values[Builder] junk <<<"${value//,/}"
;;
#Links Created 4,479
'Links Created'*)
value="${line#Links Created }"
value=${value//_/}
read values[Connector] junk <<<"${value//,/}"
;;
#Control Fields Created 2,340
'Control Fields Created'*)
value="${line#Control Fields Created }"
value=${value//_/}
read values[Mind_Controller] junk <<<"${value//,/}"
;;
#Mind Units Captured 155,815 MUs
'Mind Units Captured'*)
value="${line#Mind Units Captured }"
value=${value//_/}
read values[MU] junk <<<"${value//,/}"
;;
#Longest Link Ever Created 3 km
'Longest Link Ever Created'*)
value="${line#Longest Link Ever Created }"
value=${value//_/}
read values[Longest_Link] junk <<<"${value//,/}"
;;
#Largest Control Field 11,588 MUs
'Largest Control Field'*)
value="${line#Largest Control Field }"
value=${value//_/}
read values[Largest_Field] junk <<<"${value//,/}"
;;
#XM Recharged 92,120,959 XM
'XM Recharged'*)
value="${line#XM Recharged }"
value=${value//_/}
read values[Recharger] junk <<<"${value//,/}"
;;
#Portals Captured 2,022
'Portals Captured'*)
value="${line#Portals Captured }"
value=${value//_/}
read values[Liberator] junk <<<"${value//,/}"
;;
#Unique Portals Captured 375
'Unique Portals Captured'*)
value="${line#Unique Portals Captured }"
value=${value//_/}
read values[Pioneer] junk <<<"${value//,/}"
;;
#Mods Deployed 995
'Mods Deployed'*)
value="${line#Mods Deployed }"
value=${value//_/}
read values[Engineer] junk <<<"${value//,/}"
;;
#Resonators Destroyed 15,855
'Resonators Destroyed'*)
value="${line#Resonators Destroyed }"
value=${value//_/}
read values[Purifier] junk <<<"${value//,/}"
;;
#Portals Neutralized 2,145
'Portals Neutralized'*)
value="${line#Portals Neutralized }"
value=${value//_/}
read values[Neutralized] junk <<<"${value//,/}"
;;
#Enemy Links Destroyed 2,725
'Enemy Links Destroyed'*)
value="${line#Enemy Links Destroyed }"
value=${value//_/}
read values[Links_Destroyed] junk <<<"${value//,/}"
;;
#Enemy Control Fields Destroyed 1,418
'Enemy Control Fields Destroyed'*)
value="${line#Enemy Control Fields Destroyed }"
value=${value//_/}
read values[Fields_Destroyed] junk <<<"${value//,/}"
;;
#Max Time Portal Held 105 days
'Max '*' Portal Held'*)
value="${line#Max * Portal Held }"
value=${value//_/}
read values[Guardian] junk <<<"${value//,/}"
;;
#Max Time Link Maintained 75 days
'Max Time Link Maintained'*)
value="${line#Max Time Link Maintained }"
value=${value//_/}
read values[Link_Maintained] junk <<<"${value//,/}"
;;
#Max Link Length x Days 89 km-days
'Max Link Length x Days'*)
value="${line#Max Link Length x Days }"
value=${value//_/}
read values[Link_Length_x_Days] junk <<<"${value//,/}"
;;
#Max Time Field Held 55 days
'Max Time Field Held'*)
value="${line#Max Time Field Held }"
value=${value//_/}
read values[Field_Held] junk <<<"${value//,/}"
;;
#Largest Field MUs x Days 58,959 MU-days
'Largest Field MU'[Ss]' x Days'*)
value="${line#Largest Field MUs x Days }"
value=${value//_/}
read values[Field_x_Days] junk <<<"${value//,/}"
;;
#Unique Missions Completed 1
'Unique Missions Completed'*)
value="${line#Unique Missions Completed }"
value=${value//_/}
read values[Mercenary] junk <<<"${value//,/}"
;;
#Hacks 25,741
'Hacks'*)
value="${line#Hacks }"
value=${value//_/}
read values[Hacker] junk <<<"${value//,/}"
;;
#Glyph Hack Points 1,022
'Glyph Hack Points'*)
value="${line#Glyph Hack Points }"
value=${value//_/}
read values[Translator] junk <<<"${value//,/}"
;;
#Agents Recruited 1
'Agents Recruited'*)
value="${line#Agents Recruited }"
value=${value//_/}
read values[Recruiter] junk <<<"${value//,/}"
;;
#Agents Recruited 1
'Consecutive Days Hacking'*)
value="${line#Consecutive Days Hacking }"
value=${value//_/}
read values[Hackaton] junk <<<"${value//,/}"
;;
esac
done
template="${!values[@]}"
updatevalues="${values[@]}"
if ((debug_import))
then
echo $'\t'"$template"
echo $'\t'"$updatevalues"
fi
rrdtool update "$rrdfile" -t "${template// /:}" "$timestamp:${updatevalues// /:}"
}

49
lib/import_images Normal file
View File

@ -0,0 +1,49 @@
#!/bin/bash
# IngRRD (https://forge.riquer.fr/p/ingrrd/)
# Copyright (C) 2014-2015 Vincent Riquer
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import_images() {
local starttime=$(date +%s) imagetime timestamp elapsed lasttime now
exec >> images.log
exec 2>> images.log
declare -r oldIFS="$IFS"
[[ -r .importing ]] && return 2
[[ -w "$rrdfile" ]] || rrdcreate
readlast
for file in dav/profile_*.png
do
[[ -r "$file" ]] || continue
IFS=_.
read junk date time junk <<<"$file"
IFS="$oldIFS"
if (( $(date '+%Y%m%d%H%M%S' -d "@${last[time]}") < $date$time ))
then
(( count++ ))
lasttime=${now:-$starttime}
echo "${file##*/}" > .importing
imagetime="${date:0:4}/${date:4:2}/${date:6:2} ${time:0:2}:${time:2:2}:${time:4:2}"
echo "$(date +"%Y/%m/%d:%H:%M:%S") - $file: $imagetime"
timestamp=$(date +%s -d "$imagetime")
image "$file" $timestamp
now=$(date +%s)
echo $'\tDuration: '$(( now - lasttime ))
fi
done
elapsed=$(( $(date +%s) - starttime ))
(( count )) && echo "$(date +"%Y/%m/%d:%H:%M:%S"): Imported $count file(s) in $elapsed seconds."
rm -f .importing
}

View File

@ -1,5 +1,21 @@
#!/bin/bash #!/bin/bash
# IngRRD (https://forge.riquer.fr/p/ingrrd/)
# Copyright (C) 2014-2015 Vincent Riquer
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
medals() { medals() {
local \ local \
stat \ stat \
@ -51,16 +67,18 @@ medals() {
then then
(( bronzecount++ )) (( bronzecount++ ))
bronzes+=( "$stat" ) bronzes+=( "$stat" )
hasbronze["$stat"]=1
else else
upbronze[last["$stat"] * 100 / bronze["$stat"]]+="$stat " (( upbronze["$stat"]=last["$stat"] * 100 / bronze["$stat"]))
fi fi
if (( last["$stat"] >= silver["$stat"] )) if (( last["$stat"] >= silver["$stat"] ))
then then
(( silvercount++ )) (( silvercount++ ))
silvers+=( "$stat" ) silvers+=( "$stat" )
hassilver["$stat"]=1
elif (( last["$stat"] >= bronze["$stat"] )) elif (( last["$stat"] >= bronze["$stat"] ))
then then
upsilver[( last["$stat"] - bronze["$stat"] ) * 100 / ( silver["$stat"] - bronze["$stat"] )]+="$stat " (( upsilver["$stat"]=( last["$stat"] - bronze["$stat"] ) * 100 / ( silver["$stat"] - bronze["$stat"] ) ))
else else
nosilver["$stat"]=1 nosilver["$stat"]=1
fi fi
@ -68,9 +86,10 @@ medals() {
then then
(( goldcount++ )) (( goldcount++ ))
golds+=( "$stat" ) golds+=( "$stat" )
hasgold["$stat"]=1
elif (( last["$stat"] >= silver["$stat"] )) elif (( last["$stat"] >= silver["$stat"] ))
then then
upgold[( last["$stat"] - silver["$stat"] ) * 100 / ( gold["$stat"] - silver["$stat"] )]+="$stat " (( upgold["$stat"]=( last["$stat"] - silver["$stat"] ) * 100 / ( gold["$stat"] - silver["$stat"] ) ))
else else
nogold["$stat"]=1 nogold["$stat"]=1
fi fi
@ -78,9 +97,10 @@ medals() {
then then
(( platinumcount++ )) (( platinumcount++ ))
platinums+=( "$stat" ) platinums+=( "$stat" )
hasplatinum["$stat"]=1
elif (( last["$stat"] >= gold["$stat"] )) elif (( last["$stat"] >= gold["$stat"] ))
then then
upplatinum[( last["$stat"] - gold["$stat"] ) * 100 / ( platinum["$stat"] - gold["$stat"] )]+="$stat " (( upplatinum["$stat"]=( last["$stat"] - gold["$stat"] ) * 100 / ( platinum["$stat"] - gold["$stat"] ) ))
else else
noplatinum["$stat"]=1 noplatinum["$stat"]=1
fi fi
@ -88,9 +108,10 @@ medals() {
then then
(( blackcount++ )) (( blackcount++ ))
blacks+=( "$stat" ) blacks+=( "$stat" )
hasblack["$stat"]=1
elif (( last["$stat"] >= platinum["$stat"] )) elif (( last["$stat"] >= platinum["$stat"] ))
then then
upblack[( last["$stat"] - platinum["$stat"] ) * 100 / ( black["$stat"] - platinum["$stat"] )]+="$stat " (( upblack["$stat"]=( last["$stat"] - platinum["$stat"]) * 100 / ( black["$stat"] - platinum["$stat"] ) ))
else else
noblack["$stat"]=1 noblack["$stat"]=1
fi fi

47
lib/print_medal Normal file
View File

@ -0,0 +1,47 @@
#!/bin/bash
# IngRRD (https://forge.riquer.fr/p/ingrrd/)
# Copyright (C) 2014-2015 Vincent Riquer
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
print_medal() {
local \
timestamp=$1 \
stat=$2 \
percent=$3 \
level=$4 \
if (( timestamp ))
then
thisdate=$(date +%Y-%m-%d -d @$timestamp)
else
thisdate="maybe some day..."
fi
img=${stat,,}
(( greenlevel = percent * 255 / 100 ))
(( redlevel = 255 - greenlevel ))
cat <<-EOHTML
<a
class="badge"
style="background:#$(printf %02x%02x $redlevel $greenlevel )00"
href="?hist&amp;start=$start&amp;end=$end#$stat">
<img
class="badge"
src="/${img//_/-}-$level.png"
title="$stat $percent%"
alt="$stat $level" />
</a>&nbsp;($thisdate)
EOHTML
}

View File

@ -1,5 +1,21 @@
#!/bin/bash #!/bin/bash
# IngRRD (https://forge.riquer.fr/p/ingrrd/)
# Copyright (C) 2014-2015 Vincent Riquer
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
read_query_string() { read_query_string() {
local \ local \
exprgraph \ exprgraph \
@ -14,6 +30,7 @@ read_query_string() {
}" }"
exprtime='[[:alnum:]-]+' exprtime='[[:alnum:]-]+'
exprgraph='[[:alpha:]_]+' exprgraph='[[:alpha:]_]+'
exprprev='[[:digit:]]+[(d(ay)?)(w(eek)?)(month)(y(ear)?)]'
while read name value while read name value
do do
case $name in case $name in
@ -32,6 +49,9 @@ read_query_string() {
show) show)
[[ $value == all ]] && show_all=1 [[ $value == all ]] && show_all=1
;; ;;
prevperiod)
[[ $value =~ $exprprev ]] && prevperiod=$value
;;
esac esac
done <<<"${query_data//=/ }" done <<<"${query_data//=/ }"
fi fi

View File

@ -1,16 +1,35 @@
#!/bin/bash #!/bin/bash
# IngRRD (https://forge.riquer.fr/p/ingrrd/)
# Copyright (C) 2014-2015 Vincent Riquer
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
readlast() { readlast() {
local \ local \
index \ index \
indices \ indices \
lastupdatelines \ lastupdatelines \
time \
values \ values \
readarray -t lastupdatelines < <( readarray -t lastupdatelines < <(
rrdtool lastupdate $rrdfile rrdtool lastupdate $rrdfile
) )
indices=( ${lastupdatelines[0]} ) indices=( ${lastupdatelines[0]} )
time=${lastupdatelines[2]%:*}
last["time"]=${time:-0}
values=( ${lastupdatelines[2]#*:} ) values=( ${lastupdatelines[2]#*:} )
for index in ${!indices[@]} for index in ${!indices[@]}
do do

39
lib/readold Normal file
View File

@ -0,0 +1,39 @@
#!/bin/bash
# IngRRD (https://forge.riquer.fr/p/ingrrd/)
# Copyright (C) 2014-2015 Vincent Riquer
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
readold() {
local when=$1 \
line \
dataindex \
empty \
id \
LANG=C
{
read line
dataindex=( $line )
read empty
read first['time'] $(
for id in ${dataindex[@]}
do
echo "first['"$id"']"
done
)
} < <(
rrdtool fetch -s "$when" "$rrdfile" AVERAGE | sed '/: nan/d'
)
}

21
lib/rrdcreate Normal file
View File

@ -0,0 +1,21 @@
#!/bin/bash
# IngRRD (https://forge.riquer.fr/p/ingrrd/)
# Copyright (C) 2014-2015 Vincent Riquer
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
rrdcreate() {
rrdtool restore ingress.xml "$rrdfile"
}

38
lib/send_headers Normal file
View File

@ -0,0 +1,38 @@
#!/bin/bash
# IngRRD (https://forge.riquer.fr/p/ingrrd/)
# Copyright (C) 2014-2015 Vincent Riquer
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
send_headers() {
local timestamp do_exit header thisdate expiredate
read timestamp < <(stat -c %Y $0 settings "$rrdfile" lib/* dav/* .importing 2>/dev/null|sort -r)
thisdate=$(LC_ALL=C TZ=GMT date +'%a, %d %b %Y %X %Z' -d @$timestamp)
expiredate=$(LC_ALL=C TZ=GMT date +'%a, %d %b %Y %X %Z' -d "+${1:-5} second")
if [[ $thisdate == $HTTP_IF_MODIFIED_SINCE ]]
then
echo "Status: 304 Not Modified"
do_exit=1
fi
echo "Last-Modified: $thisdate"
echo "Expires: $expiredate"
echo "Cache-Control: must-revalidate, max-age=${1:-5}"
while read header
do
echo "$header"
done
echo
(( do_exit )) && exit
}

View File

@ -1,5 +1,21 @@
#!/bin/bash #!/bin/bash
# IngRRD (https://forge.riquer.fr/p/ingrrd/)
# Copyright (C) 2014-2015 Vincent Riquer
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
show_current_level() { show_current_level() {
cat <<-EOHTML cat <<-EOHTML
<table class="curlevel" style="width:$(( graph_width + 97 ))px"> <table class="curlevel" style="width:$(( graph_width + 97 ))px">
@ -22,13 +38,15 @@ show_current_level() {
</a> </a>
EOHTML EOHTML
done done
for id in {100..0} for timestamp in ${!nextbronze[@]}
do do
[ -z "${upbronze[id]}" ] && continue (( timestamp )) || continue
(( greenlevel = id * 255 / 100 )) for stat in ${nextbronze[timestamp]}
do
if (( upbronze[$stat] ))
then
(( greenlevel = upbronze[$stat] * 255 / 100 ))
(( redlevel = 255 - greenlevel )) (( redlevel = 255 - greenlevel ))
for stat in ${upbronze[id]}
do
img=${stat,,} img=${stat,,}
cat <<-EOHTML cat <<-EOHTML
<a <a
@ -38,12 +56,50 @@ show_current_level() {
<img <img
class="minibadge" class="minibadge"
src="/${img//_/-}-bronze.png" src="/${img//_/-}-bronze.png"
title="$stat $id%" title="$stat ${upbronze[$stat]}%
($(date -d @$timestamp +%Y-%m-%d))"
alt="$stat bronze" /> alt="$stat bronze" />
</a> </a>
EOHTML EOHTML
fi
done done
done done
for stat in ${nextbronze[0]}
do
img=${stat,,}
if (( upbronze[$stat] ))
then
(( greenlevel = upbronze[$stat] * 255 / 100 ))
(( redlevel = 255 - greenlevel ))
cat <<-EOHTML
<a
class="badge"
style="background:#$(printf %02x%02x $redlevel $greenlevel )00"
href="?hist&amp;start=$start&amp;end=$end#$stat">
<img
class="minibadge"
src="/${img//_/-}-bronze.png"
title="$stat ${upbronze[$stat]}%
(maybe one day)"
alt="$stat bronze" />
</a>
EOHTML
else
cat <<-EOHTML
<a
class="badge"
style="background:#ff0000"
href="?hist&amp;start=$start&amp;end=$end#$stat">
<img
class="minibadge"
src="/${img//_/-}-bronze.png"
title="$stat 0%
(maybe one day)"
alt="$stat bronze" />
</a>
EOHTML
fi
done
cat <<-EOHTML cat <<-EOHTML
</td> </td>
<td class="curbadge"> <td class="curbadge">
@ -62,14 +118,16 @@ show_current_level() {
</a> </a>
EOHTML EOHTML
done done
for id in {100..0} for timestamp in ${!nextsilver[@]}
do do
[ -z "${upsilver[id]}" ] && continue (( timestamp )) || continue
(( greenlevel = id * 255 / 100 )) for stat in ${nextsilver[timestamp]}
(( redlevel = 255 - greenlevel ))
for stat in ${upsilver[id]}
do do
img=${stat,,} img=${stat,,}
if (( upsilver[$stat] ))
then
(( greenlevel = upsilver[$stat] * 255 / 100 ))
(( redlevel = 255 - greenlevel ))
cat <<-EOHTML cat <<-EOHTML
<a <a
class="badge" class="badge"
@ -78,15 +136,12 @@ show_current_level() {
<img <img
class="minibadge" class="minibadge"
src="/${img//_/-}-silver.png" src="/${img//_/-}-silver.png"
title="$stat $id%" title="$stat ${upsilver[$stat]}%
($(date -d @$timestamp +%Y-%m-%d))"
alt="$stat silver" /> alt="$stat silver" />
</a> </a>
EOHTML EOHTML
done else
done
for stat in ${!nosilver[@]}
do
img=${stat,,}
cat <<-EOHTML cat <<-EOHTML
<a <a
class="badge" class="badge"
@ -94,10 +149,48 @@ show_current_level() {
<img <img
class="nominibadge" class="nominibadge"
src="/${img//_/-}-silver.png" src="/${img//_/-}-silver.png"
title="$stat $id%" title="$stat
($(date -d @$timestamp +%Y-%m-%d))"
alt="$stat silver" /> alt="$stat silver" />
</a> </a>
EOHTML EOHTML
fi
done
done
for stat in ${nextsilver[0]}
do
img=${stat,,}
if (( upsilver[$stat] ))
then
(( greenlevel = upsilver[$stat] * 255 / 100 ))
(( redlevel = 255 - greenlevel ))
cat <<-EOHTML
<a
class="badge"
style="background:#$(printf %02x%02x $redlevel $greenlevel )00"
href="?hist&amp;start=$start&amp;end=$end#$stat">
<img
class="minibadge"
src="/${img//_/-}-silver.png"
title="$stat ${upsilver[$stat]}%
($(date -d @$timestamp +%Y-%m-%d))"
alt="$stat silver" />
</a>
EOHTML
else
cat <<-EOHTML
<a
class="badge"
href="?hist&amp;start=$start&amp;end=$end#$stat">
<img
class="nominibadge"
src="/${img//_/-}-silver.png"
title="$stat
($(date -d @$timestamp +%Y-%m-%d))"
alt="$stat silver" />
</a>
EOHTML
fi
done done
cat <<-EOHTML cat <<-EOHTML
</td> </td>
@ -117,14 +210,16 @@ show_current_level() {
</a> </a>
EOHTML EOHTML
done done
for id in {100..0} for timestamp in ${!nextgold[@]}
do do
[ -z "${upgold[id]}" ] && continue (( timestamp )) || continue
(( greenlevel = id * 255 / 100 )) for stat in ${nextgold[timestamp]}
(( redlevel = 255 - greenlevel ))
for stat in ${upgold[id]}
do do
img=${stat,,} img=${stat,,}
if (( upgold[$stat] ))
then
(( greenlevel = upgold[$stat] * 255 / 100 ))
(( redlevel = 255 - greenlevel ))
cat <<-EOHTML cat <<-EOHTML
<a <a
class="badge" class="badge"
@ -133,15 +228,12 @@ show_current_level() {
<img <img
class="minibadge" class="minibadge"
src="/${img//_/-}-gold.png" src="/${img//_/-}-gold.png"
title="$stat $id%" title="$stat ${upgold[$stat]}%
($(date -d @$timestamp +%Y-%m-%d))"
alt="$stat gold" /> alt="$stat gold" />
</a> </a>
EOHTML EOHTML
done else
done
for stat in ${!nogold[@]}
do
img=${stat,,}
cat <<-EOHTML cat <<-EOHTML
<a <a
class="badge" class="badge"
@ -149,10 +241,48 @@ show_current_level() {
<img <img
class="nominibadge" class="nominibadge"
src="/${img//_/-}-gold.png" src="/${img//_/-}-gold.png"
title="$stat $id%" title="$stat
($(date -d @$timestamp +%Y-%m-%d))"
alt="$stat gold" /> alt="$stat gold" />
</a> </a>
EOHTML EOHTML
fi
done
done
for stat in ${nextgold[0]}
do
img=${stat,,}
if (( upgold[$stat] ))
then
(( greenlevel = upgold[$stat] * 255 / 100 ))
(( redlevel = 255 - greenlevel ))
cat <<-EOHTML
<a
class="badge"
style="background:#$(printf %02x%02x $redlevel $greenlevel )00"
href="?hist&amp;start=$start&amp;end=$end#$stat">
<img
class="minibadge"
src="/${img//_/-}-gold.png"
title="$stat ${upgold[$stat]}%
($(date -d @$timestamp +%Y-%m-%d))"
alt="$stat gold" />
</a>
EOHTML
else
cat <<-EOHTML
<a
class="badge"
href="?hist&amp;start=$start&amp;end=$end#$stat">
<img
class="nominibadge"
src="/${img//_/-}-gold.png"
title="$stat
($(date -d @$timestamp +%Y-%m-%d))"
alt="$stat gold" />
</a>
EOHTML
fi
done done
cat <<-EOHTML cat <<-EOHTML
</td> </td>
@ -172,14 +302,16 @@ show_current_level() {
</a> </a>
EOHTML EOHTML
done done
for id in {100..0} for timestamp in ${!nextplatinum[@]}
do do
[ -z "${upplatinum[id]}" ] && continue (( timestamp )) || continue
(( greenlevel = id * 255 / 100 )) for stat in ${nextplatinum[timestamp]}
(( redlevel = 255 - greenlevel ))
for stat in ${upplatinum[id]}
do do
img=${stat,,} img=${stat,,}
if (( upplatinum[$stat] ))
then
(( greenlevel = upplatinum[$stat] * 255 / 100 ))
(( redlevel = 255 - greenlevel ))
cat <<-EOHTML cat <<-EOHTML
<a <a
class="badge" class="badge"
@ -188,15 +320,12 @@ show_current_level() {
<img <img
class="minibadge" class="minibadge"
src="/${img//_/-}-platinum.png" src="/${img//_/-}-platinum.png"
title="$stat $id%" title="$stat ${upplatinum[$stat]}%
($(date -d @$timestamp +%Y-%m-%d))"
alt="$stat platinum" /> alt="$stat platinum" />
</a> </a>
EOHTML EOHTML
done else
done
for stat in ${!noplatinum[@]}
do
img=${stat,,}
cat <<-EOHTML cat <<-EOHTML
<a <a
class="badge" class="badge"
@ -204,10 +333,48 @@ show_current_level() {
<img <img
class="nominibadge" class="nominibadge"
src="/${img//_/-}-platinum.png" src="/${img//_/-}-platinum.png"
title="$stat $id%" title="$stat
($(date -d @$timestamp +%Y-%m-%d))"
alt="$stat platinum" /> alt="$stat platinum" />
</a> </a>
EOHTML EOHTML
fi
done
done
for stat in ${nextplatinum[0]}
do
img=${stat,,}
if (( upplatinum[$stat] ))
then
(( greenlevel = upplatinum[$stat] * 255 / 100 ))
(( redlevel = 255 - greenlevel ))
cat <<-EOHTML
<a
class="badge"
style="background:#$(printf %02x%02x $redlevel $greenlevel )00"
href="?hist&amp;start=$start&amp;end=$end#$stat">
<img
class="minibadge"
src="/${img//_/-}-platinum.png"
title="$stat ${upplatinum[$stat]}%
($(date -d @$timestamp +%Y-%m-%d))"
alt="$stat platinum" />
</a>
EOHTML
else
cat <<-EOHTML
<a
class="badge"
href="?hist&amp;start=$start&amp;end=$end#$stat">
<img
class="nominibadge"
src="/${img//_/-}-platinum.png"
title="$stat
($(date -d @$timestamp +%Y-%m-%d))"
alt="$stat platinum" />
</a>
EOHTML
fi
done done
cat <<-EOHTML cat <<-EOHTML
</td> </td>
@ -227,14 +394,16 @@ show_current_level() {
</a> </a>
EOHTML EOHTML
done done
for id in {100..0} for timestamp in ${!nextblack[@]}
do do
[ -z "${upblack[id]}" ] && continue (( timestamp )) || continue
(( greenlevel = id * 255 / 100 )) for stat in ${nextblack[timestamp]}
(( redlevel = 255 - greenlevel ))
for stat in ${upblack[id]}
do do
img=${stat,,} img=${stat,,}
if (( upblack[$stat] ))
then
(( greenlevel = upblack[$stat] * 255 / 100 ))
(( redlevel = 255 - greenlevel ))
cat <<-EOHTML cat <<-EOHTML
<a <a
class="badge" class="badge"
@ -243,15 +412,12 @@ show_current_level() {
<img <img
class="minibadge" class="minibadge"
src="/${img//_/-}-black.png" src="/${img//_/-}-black.png"
title="$stat $id%" title="$stat ${upblack[$stat]}%
($(date -d @$timestamp +%Y-%m-%d))"
alt="$stat black" /> alt="$stat black" />
</a> </a>
EOHTML EOHTML
done else
done
for stat in ${!noblack[@]}
do
img=${stat,,}
cat <<-EOHTML cat <<-EOHTML
<a <a
class="badge" class="badge"
@ -259,10 +425,48 @@ show_current_level() {
<img <img
class="nominibadge" class="nominibadge"
src="/${img//_/-}-black.png" src="/${img//_/-}-black.png"
title="$stat $id%" title="$stat
($(date -d @$timestamp +%Y-%m-%d))"
alt="$stat black" /> alt="$stat black" />
</a> </a>
EOHTML EOHTML
fi
done
done
for stat in ${nextblack[0]}
do
img=${stat,,}
if (( upblack[$stat] ))
then
(( greenlevel = upblack[$stat] * 255 / 100 ))
(( redlevel = 255 - greenlevel ))
cat <<-EOHTML
<a
class="badge"
style="background:#$(printf %02x%02x $redlevel $greenlevel )00"
href="?hist&amp;start=$start&amp;end=$end#$stat">
<img
class="minibadge"
src="/${img//_/-}-black.png"
title="$stat ${upblack[$stat]}%
(maybe one day)"
alt="$stat black" />
</a>
EOHTML
else
cat <<-EOHTML
<a
class="badge"
href="?hist&amp;start=$start&amp;end=$end#$stat">
<img
class="nominibadge"
src="/${img//_/-}-black.png"
title="$stat
(maybe one day)"
alt="$stat black" />
</a>
EOHTML
fi
done done
cat <<-EOHTML cat <<-EOHTML
</td> </td>

View File

@ -1,3 +1,19 @@
# IngRRD (https://forge.riquer.fr/p/ingrrd/)
# Copyright (C) 2014-2015 Vincent Riquer
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
server { server {
listen 80; listen 80;
listen [::]:80; listen [::]:80;

128
settings
View File

@ -1,5 +1,21 @@
# IngRRD (https://forge.riquer.fr/p/ingrrd/)
# Copyright (C) 2014-2015 Vincent Riquer
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# Path to your fastcgi_cache (optional). # Path to your fastcgi_cache (optional).
#CACHE_DIR=/var/www/ingRRD/cache CACHE_DIR=/web/ingress-stats.riquer.fr/cache/
## FIXME change this according to your URLs: ## FIXME change this according to your URLs:
# #
@ -8,6 +24,8 @@
# /cgi/$user/add.html # /cgi/$user/add.html
IFS=/ read garbage garbage webuser garbage <<<"$REQUEST_URI" IFS=/ read garbage garbage webuser garbage <<<"$REQUEST_URI"
debug_import=3
rrdfile=ingress.rrd rrdfile=ingress.rrd
graph_width=800 graph_width=800
@ -29,39 +47,46 @@ L14color=8B1479
L15color=6B127D L15color=6B127D
L16color=591494 L16color=591494
default_start=-604800 default_prevperiod=1month
default_end=1209600 now=$(date +%s)
(( default_start = now - 604800 ))
(( default_end = now + 1209600 ))
start=$default_start start=$default_start
end=$default_end end=$default_end
prevperiod=$default_prevperiod
uinames=( declare -A uinames=(
AP [AP]=AP
"Unique Portals Visited" [Explorer]="Unique Portals Visited"
"Portals Discovered" [Seer]="Portals Discovered"
"XM Collected" [XM]="XM Collected"
"Distance Walked" [Walked]="Distance Walked"
"Resonators Deployed" [Builder]="Resonators Deployed"
"Links Created" [Connector]="Links Created"
"Control Fields Created" [Mind_Controller]="Control Fields Created"
"Mind Units Captured" [MU]="Mind Units Captured"
"Longest Link Ever Created" [Longest_Link]="Longest Link Ever Created"
"Largest Control Field" [Largest_Field]="Largest Control Field"
"XM Recharged" [Recharger]="XM Recharged"
"Portals Captured" [Liberator]="Portals Captured"
"Unique Portals Captured" [Pioneer]="Unique Portals Captured"
"Mods Deployed" [Engineer]="Mods Deployed"
"Resonators Destroyed" [Purifier]="Resonators Destroyed"
"Portals Neutralized" [Neutralized]="Portals Neutralized"
"Enemy Links Destroyed" [Links_Destroyed]="Enemy Links Destroyed"
"Enemy Control Fields Destroyed" [Fields_Destroyed]="Enemy Control Fields Destroyed"
"Max Time Portal Held" [Guardian]="Max Time Portal Held"
"Max Time Link Maintained" [Link_Maintained]="Max Time Link Maintained"
"Max Link Length x Days" [Link_Length_x_Days]="Max Link Length x Days"
"Max Time Field Held" [Field_Held]="Max Time Field Held"
"Largest Field MUs x Days" [Field_x_Days]="Largest Field MUs x Days"
"Unique missions completed" [Mercenary]="Unique missions completed"
Hacks [Hacker]=Hacks
[Translator]="Glyph Hack Points"
[Recruiter]="Agents Recruited"
[Hackaton]="Consecutive Days Hacking"
) )
dsnames=( dsnames=(
AP AP
@ -90,22 +115,29 @@ dsnames=(
Field_x_Days Field_x_Days
Mercenary Mercenary
Hacker Hacker
Translator
Recruiter
Hackaton
) )
medals=( medals=(
Explorer Explorer
Seer Seer
Hacker Walked
Builder Builder
Connector Connector
Mind_Controller Mind_Controller
MU
Recharger Recharger
Liberator Liberator
Pioneer Pioneer
Purifier Purifier
Guardian Guardian
Mercenary
Engineer Engineer
Walked Hacker
Translator
Recruiter
Hackaton
Mercenary
) )
## (0) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ## (0) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
@ -199,3 +231,33 @@ silver["Mercenary"]=25
gold["Mercenary"]=100 gold["Mercenary"]=100
platinum["Mercenary"]=200 platinum["Mercenary"]=200
black["Mercenary"]=500 black["Mercenary"]=500
bronze["Recruiter"]=2
silver["Recruiter"]=10
gold["Recruiter"]=25
platinum["Recruiter"]=50
black["Recruiter"]=100
bronze["Translator"]=200
silver["Translator"]=2000
gold["Translator"]=6000
platinum["Translator"]=20000
black["Translator"]=50000
bronze["MU"]=5000
silver["MU"]=50000
gold["MU"]=250000
platinum["MU"]=1000000
black["MU"]=4000000
bronze["Hackaton"]=15
silver["Hackaton"]=30
gold["Hackaton"]=60
platinum["Hackaton"]=180
black["Hackaton"]=365
#bronze[""]=
#silver[""]=
#gold[""]=
#platinum[""]=
#black[""]=