From 9bbb4a04ff14242c82c681fea7af2475a8cbaf40 Mon Sep 17 00:00:00 2001 From: Vincent Riquer Date: Fri, 20 Jun 2014 17:09:52 +0200 Subject: [PATCH] centralize settings --- README | 26 ++------ add | 38 +----------- add.html | 54 +---------------- index | 115 +----------------------------------- settings | 177 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 187 insertions(+), 223 deletions(-) create mode 100644 settings diff --git a/README b/README index aa835e6..c9e84f0 100644 --- a/README +++ b/README @@ -1,35 +1,19 @@ +settings +======== + +Edit to your need + graph ===== RRD rendering. -Lines 7-22: - Level colors for the AP graph. Same as resonators/bursters for levels 1 to 8 -(thanks @globulator). -Find a nice scheme for higher levels and send me your patch. - -Lines 24,25: - You may want to adjust the default view (in seconds relative to the -current time). - -Lines 93,95: - Choose which stats to show. - add.html ======== Update form. Should be prefilled with last inserted data. -No change needed. - add === Process POST data and updates RRD file. Optionally clears CGI cache. - -Line 14: - Set to your CGI/fastcgi cache to enable cache purge on RRD updates - -Line 19,21: - Choose the right scheme for the extraction of the username from the -URL. diff --git a/add b/add index e791881..0fff427 100755 --- a/add +++ b/add @@ -1,14 +1,6 @@ #!/bin/bash -# Path to your fastcgi_cache (optional). -#CACHE_DIR=/var/www/ingRRD/cache - -## FIXME change this according to your URLs: -# -# /$user/add.html -#IFS=/ read garbage webuser garbage <<<"$REQUEST_URI" -# /cgi/$user/add.html -IFS=/ read garbage garbage webuser garbage <<<"$REQUEST_URI" +. settings if [[ $REQUEST_METHOD != POST ]] then @@ -51,36 +43,10 @@ else exit fi -dsnames=( - AP - Explorer - Seer - XM - Hacker - Builder - Connector - Mind_Controller - MU - Longest_Link - Largest_Field - Recharger - Liberator - Pioneer - Purifier - Neutralized - Links_Destroyed - Fields_Destroyed - Walked - Guardian - Link_Maintained - Link_Length_x_Days - Field_Held - Field_x_Days -) data=N for dsname in "${dsnames[@]}" do - data+=:${POST["$dsname"]} + data+=:${POST["$dsname"]:=U} echo "$dsname....${POST["$dsname"]}" done rrdtool update ingress.rrd "$data" diff --git a/add.html b/add.html index 8881f28..c329e9d 100755 --- a/add.html +++ b/add.html @@ -1,5 +1,7 @@ #!/bin/bash +. settings + if [ -n "$QUERY_STRING" ] then query_data="${QUERY_STRING//&/ @@ -19,58 +21,6 @@ then done <<<"${query_data//=/ }" fi -uinames=( - AP - "Unique Portals Visited" - "Portals Discovered" - "XM Collected" - Hacks - "Resonators Deployed" - "Links Created" - "Control Fields Created" - "Mind Units Captured" - "Longest Link Ever Created" - "Largest Control Field" - "XM Recharged" - "Portals Captured" - "Unique Portals Captured" - "Resonators Destroyed" - "Portals Neutralized" - "Enemy Links Destroyed" - "Enemy Control Fields Destroyed" - "Distance Walked" - "Max Time Portal Held" - "Max Time Link Maintained" - "Max Link Length x Days" - "Max Time Field Held" - "Largest Field MUs x Days" -) -dsnames=( - AP - Explorer - Seer - XM - Hacker - Builder - Connector - Mind_Controller - MU - Longest_Link - Largest_Field - Recharger - Liberator - Pioneer - Purifier - Neutralized - Links_Destroyed - Fields_Destroyed - Walked - Guardian - Link_Maintained - Link_Length_x_Days - Field_Held - Field_x_Days -) readprevvalues() { shift for arg diff --git a/index b/index index 0592fe2..6c0f752 100755 --- a/index +++ b/index @@ -1,119 +1,6 @@ #!/bin/bash -rrdfile=ingress.rrd - -graph_width=800 - -L1color=FFCF58 -L2color=FFA52E -L3color=FF7110 -L4color=E70000 -L5color=FF2691 -L6color=EF24CE -L7color=C221E1 -L8color=9523F8 -L9color=000000 -L10color=000000 -L11color=000000 -L12color=000000 -L13color=000000 -L14color=000000 -L15color=000000 -L16color=000000 - -default_start=-604800 -default_end=1209600 - -start=$default_start -end=$default_end - -medals=( - Explorer - Seer - Hacker - Builder - Connector - Mind_Controller - Recharger - Liberator - Pioneer - Purifier - Guardian -) - -## (0) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 -lvl=( . 0 2500 20000 70000 150000 300000 600000 1200000 2400000 4000000 6000000 8400000 12000000 17000000 24000000 40000000 ) -lvlsilver=( . 0 0 0 0 0 0 0 0 4 5 6 7 0 0 0 0 ) -lvlgold=( . 0 0 0 0 0 0 0 0 1 2 4 6 7 0 0 0 ) -lvlplatinum=( . 0 0 0 0 0 0 0 0 0 0 0 0 1 2 3 4 ) -lvlblack=( . 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 ) - -declare -A bronze silver gold platinum black -bronze["Explorer"]=100 -silver["Explorer"]=1000 -gold["Explorer"]=2000 -platinum["Explorer"]=10000 -black["Explorer"]=30000 - -bronze["Seer"]=10 -silver["Seer"]=50 -gold["Seer"]=200 -platinum["Seer"]=500 -black["Seer"]=5000 - -bronze["Hacker"]=2000 -silver["Hacker"]=10000 -gold["Hacker"]=30000 -platinum["Hacker"]=100000 -black["Hacker"]=200000 - -bronze["Builder"]=2000 -silver["Builder"]=10000 -gold["Builder"]=30000 -platinum["Builder"]=100000 -black["Builder"]=200000 - -bronze["Connector"]=50 -silver["Connector"]=1000 -gold["Connector"]=5000 -platinum["Connector"]=25000 -black["Connector"]=100000 - -bronze["Mind_Controller"]=100 -silver["Mind_Controller"]=500 -gold["Mind_Controller"]=2000 -platinum["Mind_Controller"]=10000 -black["Mind_Controller"]=40000 - -bronze["Recharger"]=100000 -silver["Recharger"]=1000000 -gold["Recharger"]=3000000 -platinum["Recharger"]=10000000 -black["Recharger"]=25000000 - -bronze["Liberator"]=100 -silver["Liberator"]=1000 -gold["Liberator"]=5000 -platinum["Liberator"]=15000 -black["Liberator"]=40000 - -bronze["Pioneer"]=20 -silver["Pioneer"]=200 -gold["Pioneer"]=1000 -platinum["Pioneer"]=5000 -black["Pioneer"]=20000 - -bronze["Purifier"]=2000 -silver["Purifier"]=10000 -gold["Purifier"]=30000 -platinum["Purifier"]=100000 -black["Purifier"]=300000 - -bronze["Guardian"]=3 -silver["Guardian"]=10 -gold["Guardian"]=20 -platinum["Guardian"]=90 -black["Guardian"]=150 +. settings if [ -n "$QUERY_STRING" ] then diff --git a/settings b/settings new file mode 100644 index 0000000..765e0c2 --- /dev/null +++ b/settings @@ -0,0 +1,177 @@ +# Path to your fastcgi_cache (optional). +#CACHE_DIR=/var/www/ingRRD/cache + +## FIXME change this according to your URLs: +# +# /$user/add.html +#IFS=/ read garbage webuser garbage <<<"$REQUEST_URI" +# /cgi/$user/add.html +IFS=/ read garbage garbage webuser garbage <<<"$REQUEST_URI" + +rrdfile=ingress.rrd + +graph_width=800 + +L1color=FFCF58 +L2color=FFA52E +L3color=FF7110 +L4color=E70000 +L5color=FF2691 +L6color=EF24CE +L7color=C221E1 +L8color=9523F8 +L9color=000000 +L10color=000000 +L11color=000000 +L12color=000000 +L13color=000000 +L14color=000000 +L15color=000000 +L16color=000000 + +default_start=-604800 +default_end=1209600 + +start=$default_start +end=$default_end + +uinames=( + AP + "Unique Portals Visited" + "Portals Discovered" + "XM Collected" + Hacks + "Resonators Deployed" + "Links Created" + "Control Fields Created" + "Mind Units Captured" + "Longest Link Ever Created" + "Largest Control Field" + "XM Recharged" + "Portals Captured" + "Unique Portals Captured" + "Resonators Destroyed" + "Portals Neutralized" + "Enemy Links Destroyed" + "Enemy Control Fields Destroyed" + "Distance Walked" + "Max Time Portal Held" + "Max Time Link Maintained" + "Max Link Length x Days" + "Max Time Field Held" + "Largest Field MUs x Days" +) +dsnames=( + AP + Explorer + Seer + XM + Hacker + Builder + Connector + Mind_Controller + MU + Longest_Link + Largest_Field + Recharger + Liberator + Pioneer + Purifier + Neutralized + Links_Destroyed + Fields_Destroyed + Walked + Guardian + Link_Maintained + Link_Length_x_Days + Field_Held + Field_x_Days +) +medals=( + Explorer + Seer + Hacker + Builder + Connector + Mind_Controller + Recharger + Liberator + Pioneer + Purifier + Guardian +) + +## (0) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 +lvl=( . 0 2500 20000 70000 150000 300000 600000 1200000 2400000 4000000 6000000 8400000 12000000 17000000 24000000 40000000 ) +lvlsilver=( . 0 0 0 0 0 0 0 0 4 5 6 7 0 0 0 0 ) +lvlgold=( . 0 0 0 0 0 0 0 0 1 2 4 6 7 0 0 0 ) +lvlplatinum=( . 0 0 0 0 0 0 0 0 0 0 0 0 1 2 3 4 ) +lvlblack=( . 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 ) + +declare -A bronze silver gold platinum black +bronze["Explorer"]=100 +silver["Explorer"]=1000 +gold["Explorer"]=2000 +platinum["Explorer"]=10000 +black["Explorer"]=30000 + +bronze["Seer"]=10 +silver["Seer"]=50 +gold["Seer"]=200 +platinum["Seer"]=500 +black["Seer"]=5000 + +bronze["Hacker"]=2000 +silver["Hacker"]=10000 +gold["Hacker"]=30000 +platinum["Hacker"]=100000 +black["Hacker"]=200000 + +bronze["Builder"]=2000 +silver["Builder"]=10000 +gold["Builder"]=30000 +platinum["Builder"]=100000 +black["Builder"]=200000 + +bronze["Connector"]=50 +silver["Connector"]=1000 +gold["Connector"]=5000 +platinum["Connector"]=25000 +black["Connector"]=100000 + +bronze["Mind_Controller"]=100 +silver["Mind_Controller"]=500 +gold["Mind_Controller"]=2000 +platinum["Mind_Controller"]=10000 +black["Mind_Controller"]=40000 + +bronze["Recharger"]=100000 +silver["Recharger"]=1000000 +gold["Recharger"]=3000000 +platinum["Recharger"]=10000000 +black["Recharger"]=25000000 + +bronze["Liberator"]=100 +silver["Liberator"]=1000 +gold["Liberator"]=5000 +platinum["Liberator"]=15000 +black["Liberator"]=40000 + +bronze["Pioneer"]=20 +silver["Pioneer"]=200 +gold["Pioneer"]=1000 +platinum["Pioneer"]=5000 +black["Pioneer"]=20000 + +bronze["Purifier"]=2000 +silver["Purifier"]=10000 +gold["Purifier"]=30000 +platinum["Purifier"]=100000 +black["Purifier"]=300000 + +bronze["Guardian"]=3 +silver["Guardian"]=10 +gold["Guardian"]=20 +platinum["Guardian"]=90 +black["Guardian"]=150 +