-
Notifications
You must be signed in to change notification settings - Fork 0
/
funzioni.php
executable file
·234 lines (192 loc) · 7.44 KB
/
funzioni.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
<?php
/*
Copyright (C) 2010-2019 Italian Linux Society - http://www.linux.it
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/>.
*/
?>
<?php function lugheader ($title, $extracss = null, $extrajs = null) { ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="it">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="language" content="italian" />
<meta name="robots" content="noarchive" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://www.linux.it/shared/index.php?f=bootstrap.css" rel="stylesheet" type="text/css" />
<link href="https://www.linux.it/shared/index.php?f=main.css" rel="stylesheet" type="text/css" />
<meta name="dcterms.creator" content="Italian Linux Society" />
<meta name="dcterms.type" content="Text" />
<link rel="publisher" href="http://www.ils.org/" />
<meta name="twitter:title" content="La Libertà non ha Prezzo" />
<meta name="twitter:creator" content="@ItaLinuxSociety" />
<meta name="twitter:card" content="summary" />
<meta name="twitter:url" content="http://donazioni.linux.it/" />
<meta name="twitter:image" content="http://donazioni.linux.it/immagini/tw.png" />
<meta property="og:site_name" content="Donazioni" />
<meta property="og:title" content="Donazioni" />
<meta property="og:url" content="http://donazioni.linux.it/" />
<meta property="og:image" content="http://donazioni.linux.it/immagini/fb.png" />
<meta property="og:type" content="website" />
<meta property="og:country-name" content="Italy" />
<meta property="og:email" content="webmaster@linux.it" />
<meta property="og:locale" content="it_IT" />
<meta property="og:description" content="La Libertà non ha Prezzo" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js"></script>
<?php
if ($extracss != null)
foreach ($extracss as $e) {
?>
<link href="<?php echo $e; ?>" rel="stylesheet" type="text/css" />
<?php
}
if ($extrajs != null)
foreach ($extrajs as $e) {
?>
<script type="text/javascript" src="<?php echo $e; ?>"></script>
<?php
}
?>
<title><?php echo $title; ?></title>
</head>
<body>
<div id="header">
<img src="/immagini/logo.png" alt="" />
<div id="maintitle">Donazioni</div>
<div id="payoff">La libertà non ha prezzo</div>
<div class="menu">
<a class="generalink" href="/">Home</a>
<a class="generalink" href="/progetti/">Progetti Passati</a>
<a class="generalink" href="/contatti/">Contatti</a>
<p class="social mt-2">
<a href="https://twitter.com/ItaLinuxSociety"><img src="https://www.linux.it/shared/index.php?f=immagini/twitter.png"></a>
<a href="https://www.facebook.com/ItaLinuxSociety/"><img src="https://www.linux.it/shared/index.php?f=immagini/facebook.png"></a>
<a href="https://github.com/ItalianLinuxSociety/Donazioni"><img src="https://www.linux.it/shared/index.php?f=immagini/github.png"></a>
</p>
</div>
</div>
<?php
}
function lugfooter () {
?>
<div id="ils_footer" class="mt-5">
<div class="container">
<div class="row">
<div class="col-md-3">
<span style="text-align: center; display: block">
<a href="http://www.gnu.org/licenses/agpl-3.0-standalone.html" rel="license">
<img src="https://www.linux.it/shared/index.php?f=immagini/agpl3.svg" style="border-width:0" alt="AGPLv3 License">
</a>
<a href="http://creativecommons.org/publicdomain/zero/1.0/deed.en_US" rel="license">
<img src="https://www.linux.it/shared/index.php?f=immagini/cczero.png" style="border-width:0" alt="Creative Commons License">
</a>
</span>
</div>
<div class="col-md-3">
<h2>RESTA AGGIORNATO!</h2>
<script type="text/javascript" src="https://www.linux.it/external/widgetnewsletter.js"></script>
<div id="widgetnewsletter"></div>
</div>
<div class="col-md-3">
<h2>Amici</h2>
<p style="text-align: center">
<a href="http://www.ils.org/info#aderenti">
<img src="http://www.ils.org/sites/ils.org/files/associazioni/getrand.php" border="0" /><br />
Scopri tutte le associazioni che hanno aderito a ILS.
</a>
</p>
</div>
<div class="col-md-3">
<h2>Network</h2>
<script type="text/javaScript" src="http://www.linux.it/external/widgetils.php?referrer=donazioni"></script>
<div id="widgetils"></div>
</div>
</div>
</div>
<div style="clear: both"></div>
</div>
<!-- Piwik -->
<script type="text/javascript">
var _paq = _paq || [];
_paq.push(['disableCookies']);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//pergamena.lugbs.linux.it/";
_paq.push(['setTrackerUrl', u+'piwik.php']);
_paq.push(['setSiteId', 20]);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<noscript><p><img src="//pergamena.lugbs.linux.it/piwik.php?idsite=20" style="border:0;" alt="" /></p></noscript>
<!-- End Piwik Code -->
</body>
</html>
<?php
}
function read_donations_file($filename, $target) {
$total_amount = 0;
$total_quantity = 0;
$target = strtolower($target);
if (file_exists($filename) == true) {
$rows = file($filename);
foreach ($rows as $row) {
$row = trim($row);
list($date, $person, $amount, $scope) = explode('|', $row);
$scope = strtolower($scope);
if (strpos($scope, $target) !== false) {
$total_amount += round($amount);
$total_quantity += 1;
}
}
}
return array($total_amount, $total_quantity);
}
function recap_donations($target) {
list($pp_amount, $pp_quantity) = read_donations_file($_SERVER['DOCUMENT_ROOT'] . '/data/summary.txt', $target);
list($ma_amount, $ma_quantity) = read_donations_file($_SERVER['DOCUMENT_ROOT'] . '/data/manual.txt', $target);
return array($pp_amount + $ma_amount, $pp_quantity + $ma_quantity);
}
function do_sums($project, $days) {
list($amount, $quantity) = recap_donations($project->tag);
$target = $project->target;
$ils_amount = $project->ils_fund;
?>
<div class="col-4 text-right sums">
<p>
<b><?php echo $amount ?> €</b>
<span>donati da <?php echo $quantity ?> persone</span>
</p>
<?php if($ils_amount == 'match'): ?>
<p>
<b><?php echo (($amount * 2) > $target ? $target / 2 : $amount) ?> €</b>
<span>fondo Italian Linux Society</span>
</p>
<?php elseif($ils_amount != 0): ?>
<p>
<b><?php echo $ils_amount ?> €</b>
<span>fondo Italian Linux Society</span>
</p>
<?php endif ?>
<p>
<b><?php echo ($ils_amount == 'match') ? ($amount * 2) : ($ils_amount + $amount) ?> €</b>
<span>raccolti su <?php echo $target ?> €</span>
</p>
<?php if($days <= 0): ?>
<p>
<b><?php echo $days ?></b>
<span>giorni alla chiusura della raccolta per questo progetto</span>
</p>
<?php endif ?>
</div>
<?php
}