Compare commits

..

No commits in common. "prod" and "master" have entirely different histories.
prod ... master

21 changed files with 454 additions and 57573 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-2015 Vincent Riquer # Copyright (C) 2014 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 "$rrdfile" |grep index) done < <(rrdtool info ingress.rrd |grep index)
for ds in ${dsnames[@]} for ds in ${dsnames[@]}
do do
if [[ ! ${datasets[@]} =~ $ds ]] if [[ ! ${datasets[@]} =~ $ds ]]
then then
cp -f "$rrdfile" "$rrdfile".bak_add_$ds cp -f ingress.rrd ingress.rrd.bak_add_$ds
./dsaddtor.pl "$rrdfile" $ds GAUGE $((48*60*60)) 0 NaN ./dsaddtor.pl ingress.rrd $ds GAUGE $((48*60*60)) 0 NaN
fi fi
done done
data=N data=N
@ -82,4 +82,10 @@ do
done done
echo ${POST["innovator"]} > .innovator echo ${POST["innovator"]} > .innovator
rrdtool update "$rrdfile" -t $template "$data" rrdtool update ingress.rrd -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-2015 Vincent Riquer # Copyright (C) 2014 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,10 +42,45 @@ cat <<-EOHTML
EOHTML EOHTML
if ! [ -w "$rrdfile" ] if ! [ -w "$rrdfile" ]
then then
rrdcreate || { rrdtool create ingress.rrd -s $((60*60)) \
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
@ -117,10 +152,9 @@ cat <<-EOHTML
<ul> <ul>
EOHTML EOHTML
for indice in ${dsnames[@]} for indice in ${!uinames[@]}
do do
[[ -z "${uinames[$indice]}" ]] && continue echo "<li><input type=\"text\" name=\"${dsnames[indice]}\" value=\"${last["${dsnames[indice]}"]}\" /> ${uinames[indice]}</li>"
echo "<li><input type=\"text\" name=\"$indice\" value=\"${last["$indice"]}\" /> ${uinames[$indice]}</li>"
done done
cat <<-EOHTML cat <<-EOHTML

127
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-2015 Vincent Riquer # Copyright (C) 2014 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,10 +24,43 @@ 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:Translator:Hackaton:Recruiter 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
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
@ -43,51 +76,24 @@ 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 "$rrdfile" -t $template "${data//:0/:U}" 2>&1 rrdtool update ingress.rrd -t $template "$data" 2>&1
done <<<"${POST["data"]}" done <<<"${POST["data"]}"
else
import_images &
send_headers <<-EOHead
content-type: text/xml
EOHead
if [ -n "$CACHE_DIR" ]
then
find "$CACHE_DIR" -type f -delete
echo $'\nCache cleared!'
fi
else
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">
@ -101,7 +107,43 @@ else
EOHTML EOHTML
if ! [ -w "$rrdfile" ] if ! [ -w "$rrdfile" ]
then then
rrdcreate || { rrdtool create ingress.rrd -s $((60*60)) \
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>
@ -118,7 +160,6 @@ 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" />

442
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-2015 Vincent Riquer # Copyright (C) 2014 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,25 +22,26 @@ 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"
@ -51,6 +52,15 @@ 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">
@ -60,12 +70,6 @@ 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
@ -112,9 +116,6 @@ 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">
@ -131,217 +132,150 @@ 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
cat <<-EOHTML echo "<tr class=\"nextlevel\"><th class=\"level\">$level</th>"
<tr class="nextlevel">
<th class="level">$level</th>
EOHTML
fi fi
echo "${tableline[@]}" if (( last["AP"] >= lvl[level] ))
if (( level > curlevel ))
then then
(( maxtimestamp < prevtimestamp )) \ echo '<td class="AP" style="background:lightgreen">'
&& maxtimestamp=$prevtimestamp printf "%'li" ${lvl[level]}
if (( maxtimestamp )) echo '</td>'
then else
cat <<-EOHTML readable=$(printf "%'li" ${lvl[level]})
<td class="date">$(date +%Y-%m-%d -d @$maxtimestamp)</td> echo '<td class="AP" style="background:lightgrey">'"${readable// /&nbsp;}"
EOHTML readable=$(printf "%'li" $(( last["AP"] - lvl[level] )))
else echo "<br />(<span class=\"missing\">${readable// /&nbsp;}</span>)</td>"
cat <<-EOHTML fi
<td class="date">In more than 5 years</td> if (( silvercount >= lvlsilver[level] ))
EOHTML then
fi 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
<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//_/-}-silver.png"
title="$stat $id%"
alt="$stat silver" />
</a>
EOHTML
(( count++ == lvlsilver[level] - silvercount )) && break 2
done
done
echo '</td>'
fi
if (( goldcount >= lvlgold[level] ))
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
<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//_/-}-gold.png"
title="$stat $id%"
alt="$stat gold" />
</a>
EOHTML
(( count++ == lvlgold[level] - goldcount )) && break 2
done
done
echo '</td>'
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>
@ -407,35 +341,21 @@ then
<table style="width:$(( graph_width + 97 ))px"> <table style="width:$(( graph_width + 97 ))px">
<tr> <tr>
<td> <td>
<a href="?hist&amp;start=$(rrdtool first "$rrdfile")&amp;end=$end">First</a> <a href="?hist&amp;start=$(( start - 604800 ))&amp;end=$end">&lt;&lt;</a>
<a href="?hist&amp;start=$(( start - 365 * 86400 ))&amp;end=$end">-Y</a> <a href="?hist&amp;start=$(( start - 86400 ))&amp;end=$end">&lt;</a>
<a href="?hist&amp;start=$(( start - 30 * 86400 ))&amp;end=$end">-M</a> <a href="?hist&amp;start=$default_start&amp;end=$end">R</a>
<a href="?hist&amp;start=$(( start - 604800 ))&amp;end=$end">-W</a> <a href="?hist&amp;start=$(( start + 86400 ))&amp;end=$end">&gt;</a>
<a href="?hist&amp;start=$(( start - 86400 ))&amp;end=$end">-D</a> <a href="?hist&amp;start=$(( start + 604800 ))&amp;end=$end">&gt;&gt;</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 - 365 * 86400 ))">-Y</a> <a href="?hist&amp;start=$start&amp;end=$(( end - 604800 ))">&lt;&lt;</a>
<a href="?hist&amp;start=$start&amp;end=$(( end - 30 * 86400 ))">-M</a> <a href="?hist&amp;start=$start&amp;end=$(( end - 86400 ))">&lt;</a>
<a href="?hist&amp;start=$start&amp;end=$(( end - 604800 ))">-W</a> <a href="?hist&amp;start=$start&amp;end=$default_end">R</a>
<a href="?hist&amp;start=$start&amp;end=$(( end - 86400 ))">-D</a> <a href="?hist&amp;start=$start&amp;end=$(( end + 86400 ))">&gt;</a>
<a href="?hist&amp;start=$start&amp;end=$now">Now</a> <a href="?hist&amp;start=$start&amp;end=$(( end + 604800 ))">&gt;&gt;</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
@ -454,7 +374,6 @@ 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
@ -496,7 +415,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-2015 Vincent Riquer Generated by <a href="https://forge.riquer.fr/p/ingrrd/">IngRRD</a> &copy; 2014 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">
@ -507,20 +426,21 @@ 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
send_headers <<-EOHead
content-type: image/png
EOHead
now=$(date +%s) now=$(date +%s)
cat <<-EOHEAD
content-type: image/png
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
EOHEAD
if [[ $graph == AP ]] if [[ $graph == AP ]]
then then
thresholds=( thresholds=(
@ -660,14 +580,16 @@ else
next=('COMMENT:\n') next=('COMMENT:\n')
fi fi
(( start - now > -1209600 )) && datastart=-1209600 (( start > -1209600 )) && datastart=-1209600
(( end - now < 157680001 )) && dataend="+157680001" (( end < 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 "${uinames[$graph]}" \ -v $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

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-2015 Vincent Riquer * Copyright (C) 2014 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,13 +59,6 @@ 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;
@ -120,7 +113,7 @@ th.AP,td.AP {
} }
th.badge,td.badge { th.badge,td.badge {
/* width: 170px;*/ width: 170px;
} }
a.badge { a.badge {

View File

@ -1,21 +1,5 @@
#!/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

View File

@ -1,127 +0,0 @@
#!/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,39 +1,11 @@
#!/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 \
@ -41,11 +13,11 @@ declare -a \
golds \ golds \
platinums \ platinums \
blacks \ blacks \
nextbronze \ upbronze \
nextsilver \ upsilver \
nextgold \ upgold \
nextplatinum \ upplatinum \
nextblack \ upblack \
declare -i \ declare -i \
bronzecount \ bronzecount \
@ -61,7 +33,6 @@ declare \
graph \ graph \
start \ start \
end \ end \
prevperiod \
want_ds=( want_ds=(
AP AP

238
lib/image
View File

@ -1,238 +0,0 @@
#!/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// /:}"
}

View File

@ -1,49 +0,0 @@
#!/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,21 +1,5 @@
#!/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 \
@ -67,18 +51,16 @@ medals() {
then then
(( bronzecount++ )) (( bronzecount++ ))
bronzes+=( "$stat" ) bronzes+=( "$stat" )
hasbronze["$stat"]=1
else else
(( upbronze["$stat"]=last["$stat"] * 100 / bronze["$stat"])) upbronze[last["$stat"] * 100 / bronze["$stat"]]+="$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["$stat"]=( last["$stat"] - bronze["$stat"] ) * 100 / ( silver["$stat"] - bronze["$stat"] ) )) upsilver[( last["$stat"] - bronze["$stat"] ) * 100 / ( silver["$stat"] - bronze["$stat"] )]+="$stat "
else else
nosilver["$stat"]=1 nosilver["$stat"]=1
fi fi
@ -86,10 +68,9 @@ 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["$stat"]=( last["$stat"] - silver["$stat"] ) * 100 / ( gold["$stat"] - silver["$stat"] ) )) upgold[( last["$stat"] - silver["$stat"] ) * 100 / ( gold["$stat"] - silver["$stat"] )]+="$stat "
else else
nogold["$stat"]=1 nogold["$stat"]=1
fi fi
@ -97,10 +78,9 @@ 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["$stat"]=( last["$stat"] - gold["$stat"] ) * 100 / ( platinum["$stat"] - gold["$stat"] ) )) upplatinum[( last["$stat"] - gold["$stat"] ) * 100 / ( platinum["$stat"] - gold["$stat"] )]+="$stat "
else else
noplatinum["$stat"]=1 noplatinum["$stat"]=1
fi fi
@ -108,10 +88,9 @@ 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["$stat"]=( last["$stat"] - platinum["$stat"]) * 100 / ( black["$stat"] - platinum["$stat"] ) )) upblack[( last["$stat"] - platinum["$stat"] ) * 100 / ( black["$stat"] - platinum["$stat"] )]+="$stat "
else else
noblack["$stat"]=1 noblack["$stat"]=1
fi fi

View File

@ -1,47 +0,0 @@
#!/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,21 +1,5 @@
#!/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 \
@ -30,7 +14,6 @@ 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
@ -49,9 +32,6 @@ 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,35 +1,16 @@
#!/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

View File

@ -1,39 +0,0 @@
#!/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'
)
}

View File

@ -1,21 +0,0 @@
#!/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"
}

View File

@ -1,38 +0,0 @@
#!/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,21 +1,5 @@
#!/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">
@ -38,15 +22,13 @@ show_current_level() {
</a> </a>
EOHTML EOHTML
done done
for timestamp in ${!nextbronze[@]} for id in {100..0}
do
(( timestamp )) || continue
for stat in ${nextbronze[timestamp]}
do do
if (( upbronze[$stat] )) [ -z "${upbronze[id]}" ] && continue
then (( greenlevel = id * 255 / 100 ))
(( 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
@ -56,50 +38,12 @@ show_current_level() {
<img <img
class="minibadge" class="minibadge"
src="/${img//_/-}-bronze.png" src="/${img//_/-}-bronze.png"
title="$stat ${upbronze[$stat]}% title="$stat $id%"
($(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">
@ -118,16 +62,14 @@ show_current_level() {
</a> </a>
EOHTML EOHTML
done done
for timestamp in ${!nextsilver[@]} for id in {100..0}
do
(( timestamp )) || continue
for stat in ${nextsilver[timestamp]}
do do
img=${stat,,} [ -z "${upsilver[id]}" ] && continue
if (( upsilver[$stat] )) (( greenlevel = id * 255 / 100 ))
then (( redlevel = 255 - greenlevel ))
(( greenlevel = upsilver[$stat] * 255 / 100 )) for stat in ${upsilver[id]}
(( redlevel = 255 - greenlevel )) do
img=${stat,,}
cat <<-EOHTML cat <<-EOHTML
<a <a
class="badge" class="badge"
@ -136,48 +78,15 @@ show_current_level() {
<img <img
class="minibadge" class="minibadge"
src="/${img//_/-}-silver.png" src="/${img//_/-}-silver.png"
title="$stat ${upsilver[$stat]}% title="$stat $id%"
($(date -d @$timestamp +%Y-%m-%d))"
alt="$stat silver" /> alt="$stat silver" />
</a> </a>
EOHTML EOHTML
else done
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
done for stat in ${!nosilver[@]}
for stat in ${nextsilver[0]} do
do img=${stat,,}
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 cat <<-EOHTML
<a <a
class="badge" class="badge"
@ -185,13 +94,11 @@ show_current_level() {
<img <img
class="nominibadge" class="nominibadge"
src="/${img//_/-}-silver.png" src="/${img//_/-}-silver.png"
title="$stat title="$stat $id%"
($(date -d @$timestamp +%Y-%m-%d))"
alt="$stat silver" /> alt="$stat silver" />
</a> </a>
EOHTML EOHTML
fi done
done
cat <<-EOHTML cat <<-EOHTML
</td> </td>
<td class="curbadge"> <td class="curbadge">
@ -210,52 +117,14 @@ show_current_level() {
</a> </a>
EOHTML EOHTML
done done
for timestamp in ${!nextgold[@]} for id in {100..0}
do do
(( timestamp )) || continue [ -z "${upgold[id]}" ] && continue
for stat in ${nextgold[timestamp]} (( greenlevel = id * 255 / 100 ))
(( 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
<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
for stat in ${nextgold[0]}
do
img=${stat,,}
if (( upgold[$stat] ))
then
(( greenlevel = upgold[$stat] * 255 / 100 ))
(( redlevel = 255 - greenlevel ))
cat <<-EOHTML cat <<-EOHTML
<a <a
class="badge" class="badge"
@ -264,25 +133,26 @@ show_current_level() {
<img <img
class="minibadge" class="minibadge"
src="/${img//_/-}-gold.png" src="/${img//_/-}-gold.png"
title="$stat ${upgold[$stat]}% title="$stat $id%"
($(date -d @$timestamp +%Y-%m-%d))"
alt="$stat gold" /> alt="$stat gold" />
</a> </a>
EOHTML EOHTML
else done
cat <<-EOHTML done
<a for stat in ${!nogold[@]}
class="badge" do
href="?hist&amp;start=$start&amp;end=$end#$stat"> img=${stat,,}
<img cat <<-EOHTML
class="nominibadge" <a
src="/${img//_/-}-gold.png" class="badge"
title="$stat href="?hist&amp;start=$start&amp;end=$end#$stat">
($(date -d @$timestamp +%Y-%m-%d))" <img
alt="$stat gold" /> class="nominibadge"
</a> src="/${img//_/-}-gold.png"
EOHTML title="$stat $id%"
fi alt="$stat gold" />
</a>
EOHTML
done done
cat <<-EOHTML cat <<-EOHTML
</td> </td>
@ -302,52 +172,14 @@ show_current_level() {
</a> </a>
EOHTML EOHTML
done done
for timestamp in ${!nextplatinum[@]} for id in {100..0}
do do
(( timestamp )) || continue [ -z "${upplatinum[id]}" ] && continue
for stat in ${nextplatinum[timestamp]} (( greenlevel = id * 255 / 100 ))
(( 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
<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
for stat in ${nextplatinum[0]}
do
img=${stat,,}
if (( upplatinum[$stat] ))
then
(( greenlevel = upplatinum[$stat] * 255 / 100 ))
(( redlevel = 255 - greenlevel ))
cat <<-EOHTML cat <<-EOHTML
<a <a
class="badge" class="badge"
@ -356,25 +188,26 @@ show_current_level() {
<img <img
class="minibadge" class="minibadge"
src="/${img//_/-}-platinum.png" src="/${img//_/-}-platinum.png"
title="$stat ${upplatinum[$stat]}% title="$stat $id%"
($(date -d @$timestamp +%Y-%m-%d))"
alt="$stat platinum" /> alt="$stat platinum" />
</a> </a>
EOHTML EOHTML
else done
cat <<-EOHTML done
<a for stat in ${!noplatinum[@]}
class="badge" do
href="?hist&amp;start=$start&amp;end=$end#$stat"> img=${stat,,}
<img cat <<-EOHTML
class="nominibadge" <a
src="/${img//_/-}-platinum.png" class="badge"
title="$stat href="?hist&amp;start=$start&amp;end=$end#$stat">
($(date -d @$timestamp +%Y-%m-%d))" <img
alt="$stat platinum" /> class="nominibadge"
</a> src="/${img//_/-}-platinum.png"
EOHTML title="$stat $id%"
fi alt="$stat platinum" />
</a>
EOHTML
done done
cat <<-EOHTML cat <<-EOHTML
</td> </td>
@ -394,52 +227,14 @@ show_current_level() {
</a> </a>
EOHTML EOHTML
done done
for timestamp in ${!nextblack[@]} for id in {100..0}
do do
(( timestamp )) || continue [ -z "${upblack[id]}" ] && continue
for stat in ${nextblack[timestamp]} (( greenlevel = id * 255 / 100 ))
(( 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
<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]}%
($(date -d @$timestamp +%Y-%m-%d))"
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
($(date -d @$timestamp +%Y-%m-%d))"
alt="$stat black" />
</a>
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 cat <<-EOHTML
<a <a
class="badge" class="badge"
@ -448,25 +243,26 @@ show_current_level() {
<img <img
class="minibadge" class="minibadge"
src="/${img//_/-}-black.png" src="/${img//_/-}-black.png"
title="$stat ${upblack[$stat]}% title="$stat $id%"
(maybe one day)"
alt="$stat black" /> alt="$stat black" />
</a> </a>
EOHTML EOHTML
else done
cat <<-EOHTML done
<a for stat in ${!noblack[@]}
class="badge" do
href="?hist&amp;start=$start&amp;end=$end#$stat"> img=${stat,,}
<img cat <<-EOHTML
class="nominibadge" <a
src="/${img//_/-}-black.png" class="badge"
title="$stat href="?hist&amp;start=$start&amp;end=$end#$stat">
(maybe one day)" <img
alt="$stat black" /> class="nominibadge"
</a> src="/${img//_/-}-black.png"
EOHTML title="$stat $id%"
fi alt="$stat black" />
</a>
EOHTML
done done
cat <<-EOHTML cat <<-EOHTML
</td> </td>

View File

@ -1,19 +1,3 @@
# 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,21 +1,5 @@
# 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=/web/ingress-stats.riquer.fr/cache/ #CACHE_DIR=/var/www/ingRRD/cache
## FIXME change this according to your URLs: ## FIXME change this according to your URLs:
# #
@ -24,8 +8,6 @@ CACHE_DIR=/web/ingress-stats.riquer.fr/cache/
# /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
@ -47,46 +29,39 @@ L14color=8B1479
L15color=6B127D L15color=6B127D
L16color=591494 L16color=591494
default_prevperiod=1month default_start=-604800
now=$(date +%s) default_end=1209600
(( default_start = now - 604800 ))
(( default_end = now + 1209600 ))
start=$default_start start=$default_start
end=$default_end end=$default_end
prevperiod=$default_prevperiod
declare -A uinames=( uinames=(
[AP]=AP AP
[Explorer]="Unique Portals Visited" "Unique Portals Visited"
[Seer]="Portals Discovered" "Portals Discovered"
[XM]="XM Collected" "XM Collected"
[Walked]="Distance Walked" "Distance Walked"
[Builder]="Resonators Deployed" "Resonators Deployed"
[Connector]="Links Created" "Links Created"
[Mind_Controller]="Control Fields Created" "Control Fields Created"
[MU]="Mind Units Captured" "Mind Units Captured"
[Longest_Link]="Longest Link Ever Created" "Longest Link Ever Created"
[Largest_Field]="Largest Control Field" "Largest Control Field"
[Recharger]="XM Recharged" "XM Recharged"
[Liberator]="Portals Captured" "Portals Captured"
[Pioneer]="Unique Portals Captured" "Unique Portals Captured"
[Engineer]="Mods Deployed" "Mods Deployed"
[Purifier]="Resonators Destroyed" "Resonators Destroyed"
[Neutralized]="Portals Neutralized" "Portals Neutralized"
[Links_Destroyed]="Enemy Links Destroyed" "Enemy Links Destroyed"
[Fields_Destroyed]="Enemy Control Fields Destroyed" "Enemy Control Fields Destroyed"
[Guardian]="Max Time Portal Held" "Max Time Portal Held"
[Link_Maintained]="Max Time Link Maintained" "Max Time Link Maintained"
[Link_Length_x_Days]="Max Link Length x Days" "Max Link Length x Days"
[Field_Held]="Max Time Field Held" "Max Time Field Held"
[Field_x_Days]="Largest Field MUs x Days" "Largest Field MUs x Days"
[Mercenary]="Unique missions completed" "Unique missions completed"
[Hacker]=Hacks Hacks
[Translator]="Glyph Hack Points"
[Recruiter]="Agents Recruited"
[Hackaton]="Consecutive Days Hacking"
) )
dsnames=( dsnames=(
AP AP
@ -115,29 +90,22 @@ dsnames=(
Field_x_Days Field_x_Days
Mercenary Mercenary
Hacker Hacker
Translator
Recruiter
Hackaton
) )
medals=( medals=(
Explorer Explorer
Seer Seer
Walked Hacker
Builder Builder
Connector Connector
Mind_Controller Mind_Controller
MU
Recharger Recharger
Liberator Liberator
Pioneer Pioneer
Purifier Purifier
Guardian Guardian
Engineer
Hacker
Translator
Recruiter
Hackaton
Mercenary Mercenary
Engineer
Walked
) )
## (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
@ -231,33 +199,3 @@ 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[""]=