1<?php
2// This file is part of BOINC.
3// http://boinc.berkeley.edu
4// Copyright (C) 2008 University of California
5//
6// BOINC is free software; you can redistribute it and/or modify it
7// under the terms of the GNU Lesser General Public License
8// as published by the Free Software Foundation,
9// either version 3 of the License, or (at your option) any later version.
10//
11// BOINC is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14// See the GNU Lesser General Public License for more details.
15//
16// You should have received a copy of the GNU Lesser General Public License
17// along with BOINC.  If not, see <http://www.gnu.org/licenses/>.
18
19require_once("../inc/util.inc");
20
21check_get_args(array());
22
23if (!defined("PAYPAL_ADDRESS")) {
24    error_page(tra("This project is not accepting donations."));
25}
26
27db_init();
28
29$logged_in_user = get_logged_in_user(false);
30if ($logged_in_user) {
31    $user_id = $logged_in_user->id;
32}
33
34page_head(tra("%1 donations", PROJECT));
35
36if (function_exists("donations_intro")) {
37    donations_intro();
38} else {
39    echo "<div>".tra("This project is accepting donations via
40%1.", "<a href=\"http://www.paypal.com/\">PayPal</a>")."</div>
41        ".tra("To donate, fill in the amount you want to donate using the field below.
42        PayPal is accepting multiple currencies
43        (Canadian Dollars, Euros, Pounds Sterling, U.S. Dollars,
44         Yen, Australian Dollars, New Zealand Dollars,
45        Swiss Francs, Hong Kong Dollars, Singapore Dollars, Swedish Kronor,
46        Danish Kroner, Polish Zloty, Norwegian Kroner,
47        Hungarian Forint, Czech Koruna).
48        You can use included currency converter
49        to see the donation amount equivalent in different currencies
50        (please note that the rates are only estimates
51         and the actual amount may differ).")."
52    ";
53}
54
55echo "<script src=\"currency.js\" type=\"text/javascript\"></script>\n";
56
57$query = _mysql_query("SELECT * FROM donation_items");
58
59echo "<form name=\"calcForm\" action=\"donate.php\" method=\"post\">\n";
60start_table();
61
62// If donation_items table is filled, a list of donation targets is shown
63
64$first_row = true;
65while ($row = _mysql_fetch_object($query)) {
66    $col1 = $row->title."<br><small>".$row->description."</small>";
67
68    $query_amount = _mysql_query("SELECT SUM(payment_amount-payment_fee) AS amount FROM donation_paypal WHERE processed = 1 AND item_number = '".$row->id."'");
69    $acquired = _mysql_fetch_object($query_amount)->amount;
70    $required = $row->required;
71
72    if ($acquired > $required) {
73        $acquired = $acquired - $required;
74        $progress = 100;
75    } else {
76        $progress = round($acquired / ($required) * 100);
77        $progress2 = round($acquired / ($required) * 100,1);
78    }
79
80    $col2 = "<input style=\"float: left\" type=\"radio\" name=\"item_id\" value=\"".$row->id."\"";
81    if ($first_row) {
82        $first_row = false;
83        $col2 .= " checked=\"checked\"";
84    }
85    $col2 .= ">";
86
87    if ($progress == 0) {
88        $col2 .= "<div style=\"float: left; width: 300px; height: 18px; background-color: red; border: 1px solid #000000\">";
89    } elseif ($progress == 100) {
90        $col2 .= "<div style=\"float: left; width: 300px; height: 18px; background-color: green; border: 1px solid #000000\">";
91    } else {
92        $col2 .= "<div style=\"float: left; width: ".($progress*3 - 1)."px; height: 18px; background-color: green; border: 1px solid #000000;\" align=\"right\"><b>".$progress2."</b>%</div><div style=\"float: left; width: ".((100-$progress)*3 - 1)."px; height: 18px; background-color: red; border: 1px solid #000000;\">";
93    }
94
95    row2($col1, $col2);
96}
97
98$amount = "<select class=\"form-control\" name=\"from\" onchange=\"Cvalue();numberFormat();\" style=\"width: 200px;\">\n";
99if (DONATION_CURRENCY == "EUR") {
100    $amount .= "<option value=\"51\">Euros</option>\n";
101}
102elseif (DONATION_CURRENCY == "CAD") {
103    $amount .= "<option value=\"30\">Canadian Dollars</option>\n";
104}
105elseif (DONATION_CURRENCY == "GBP") {
106    $amount .= "<option value=\"24\">Pounds Sterling</option>\n";
107}
108elseif (DONATION_CURRENCY == "USD") {
109    $amount .= "<option value=\"3\">U.S. Dollars</option>\n";
110}
111elseif (DONATION_CURRENCY == "JPY") {
112    $amount .= "<option value=\"72\">Yen</option>\n";
113}
114elseif (DONATION_CURRENCY == "AUD") {
115    $amount .= "<option value=\"9\">Australian Dollars</option>\n";
116}
117elseif (DONATION_CURRENCY == "NZD") {
118    $amount .= "<option value=\"102\">New Zealand Dollars</option>\n";
119}
120elseif (DONATION_CURRENCY == "CHF") {
121    $amount .= "<option value=\"139\">Swiss Francs</option>\n";
122}
123elseif (DONATION_CURRENCY == "HKD") {
124    $amount .= "<option value=\"63\">Hong Kong Dollars</option>\n";
125}
126elseif (DONATION_CURRENCY == "SGD") {
127    $amount .= "<option value=\"126\">Singapore Dollars</option>\n";
128}
129elseif (DONATION_CURRENCY == "SEK") {
130    $amount .= "<option value=\"138\">Swedish Kronor</option>\n";
131}
132elseif (DONATION_CURRENCY == "DKK") {
133    $amount .= "<option value=\"42\">Danish Kroner</option>\n";
134}
135elseif (DONATION_CURRENCY == "PLN") {
136    $amount .= "<option value=\"114\">Polish Zloty</option>\n";
137}
138elseif (DONATION_CURRENCY == "NOK") {
139    $amount .= "<option value=\"106\">Norwegian Kroner</option>\n";
140}
141elseif (DONATION_CURRENCY == "HUF") {
142    $amount .= "<option value=\"64\">Hungarian Forint</option>\n";
143}
144elseif (DONATION_CURRENCY == "CZK") {
145    $amount .= "<option value=\"41\">Czech Koruna</option>\n";
146}
147$amount .= "</select>\n";
148$amount .= "<input type=\"hidden\" name=\"currency\" value=\"".DONATION_CURRENCY."\">\n";
149$amount .= "<input type=\"text\" name=\"inV\" id=\"inV\" value=\"10.00\" style=\"text-align: right; width: 80px\" onchange=\"Cvalue();numberFormat();\">\n";
150
151$estimated = "<select class=\"form-control\" name=\"to\" onchange=\"Cvalue();numberFormat();\" style=\"width: 200px;\">";
152$estimated .= "<option value=0 selected>Select currency</option>\n";
153$estimated .= "<option value=1>Afghanistan Afghani</option>\n";
154$estimated .= "<option value=2>Algerian Dinar</option>\n";
155$estimated .= "<option value=3>American Dollar</option>\n";
156$estimated .= "<option value=4>Angolan New Kwanza</option>\n";
157$estimated .= "<option value=5>Antilles Guilder</option>\n";
158$estimated .= "<option value=6>Argentine Peso</option>\n";
159$estimated .= "<option value=7>Armenia Dram</option>\n";
160$estimated .= "<option value=8>Aruba Guilder</option>\n";
161$estimated .= "<option value=9>Australian Dollar</option>\n";
162$estimated .= "<option value=10>Azerbaijan Manat</option>\n";
163$estimated .= "<option value=11>BCEAO Franc</option>\n";
164$estimated .= "<option value=12>BEAC Franc</option>\n";
165$estimated .= "<option value=13>Bahamanian Dollar</option>\n";
166$estimated .= "<option value=14>Bahraini Dinar</option>\n";
167$estimated .= "<option value=15>Barbados Dollar</option>\n";
168$estimated .= "<option value=16>Belarus Ruble</option>\n";
169$estimated .= "<option value=17>Belize Dollar</option>\n";
170$estimated .= "<option value=18>Bermuda Dollar</option>\n";
171$estimated .= "<option value=19>Bhutan Ngultrum</option>\n";
172$estimated .= "<option value=20>Bolivian Boliviano</option>\n";
173$estimated .= "<option value=21>Bosnia Marka</option>\n";
174$estimated .= "<option value=22>Botswana Pula</option>\n";
175$estimated .= "<option value=23>Brazilian Real</option>\n";
176$estimated .= "<option value=24>British Pound</option>\n";
177$estimated .= "<option value=25>Brunei Dollar</option>\n";
178$estimated .= "<option value=26>Bulgarian Lev</option>\n";
179$estimated .= "<option value=27>Burundi Franc</option>\n";
180$estimated .= "<option value=28>CFP Franc</option>\n";
181$estimated .= "<option value=29>Cambodian Riel</option>\n";
182$estimated .= "<option value=30>Canadian Dollar</option>\n";
183$estimated .= "<option value=31>Cayman Dollar</option>\n";
184$estimated .= "<option value=32>Chilean Peso</option>\n";
185$estimated .= "<option value=33>Chinese Yuan</option>\n";
186$estimated .= "<option value=34>Colombian Peso</option>\n";
187$estimated .= "<option value=35>Comoros Franc</option>\n";
188$estimated .= "<option value=36>Congolese Franc</option>\n";
189$estimated .= "<option value=37>Costa Rican Colon</option>\n";
190$estimated .= "<option value=38>Croatian Kuna</option>\n";
191$estimated .= "<option value=39>Cuban Peso</option>\n";
192$estimated .= "<option value=40>Cyprus Pound</option>\n";
193$estimated .= "<option value=41>Czech Koruna</option>\n";
194$estimated .= "<option value=42>Danish Krone</option>\n";
195$estimated .= "<option value=43>Djibouti Franc</option>\n";
196$estimated .= "<option value=44>Dominican R. Peso</option>\n";
197$estimated .= "<option value=45>East Caribbean Dollar</option>\n";
198$estimated .= "<option value=46>Egyptian Pound</option>\n";
199$estimated .= "<option value=47>El Salvador Colon</option>\n";
200$estimated .= "<option value=48>Eritrea Nakfa</option>\n";
201$estimated .= "<option value=49>Estonian Kroon</option>\n";
202$estimated .= "<option value=50>Ethiopian Birr</option>\n";
203$estimated .= "<option value=51>Euro</option>\n";
204$estimated .= "<option value=52>Falkland Pound</option>\n";
205$estimated .= "<option value=53>Fiji Dollar</option>\n";
206$estimated .= "<option value=54>Gambia Dalasi</option>\n";
207$estimated .= "<option value=55>Georgia Lari</option>\n";
208$estimated .= "<option value=56>Ghanaian Cedi</option>\n";
209$estimated .= "<option value=57>Gibraltar Pound</option>\n";
210$estimated .= "<option value=58>Guatemalan Quetzal</option>\n";
211$estimated .= "<option value=59>Guinea Franc</option>\n";
212$estimated .= "<option value=60>Guyanese Dollar</option>\n";
213$estimated .= "<option value=61>Haitian Gourde</option>\n";
214$estimated .= "<option value=62>Honduran Lempira</option>\n";
215$estimated .= "<option value=63>Hong Kong Dollar</option>\n";
216$estimated .= "<option value=64>Hungarian Forint</option>\n";
217$estimated .= "<option value=65>IRR Rial</option>\n";
218$estimated .= "<option value=66>Iceland Krona</option>\n";
219$estimated .= "<option value=67>Indian Rupee</option>\n";
220$estimated .= "<option value=68>Indonesian Rupiah</option>\n";
221$estimated .= "<option value=69>Iraqi Dinar</option>\n";
222$estimated .= "<option value=70>Israeli New Sheqel</option>\n";
223$estimated .= "<option value=71>Jamaican Dollar</option>\n";
224$estimated .= "<option value=72>Japanese Yen</option>\n";
225$estimated .= "<option value=73>Jordanian Dinar</option>\n";
226$estimated .= "<option value=74>Kazakhstan Tenge</option>\n";
227$estimated .= "<option value=75>Kenyan Shilling</option>\n";
228$estimated .= "<option value=76>Krygyzstan Som</option>\n";
229$estimated .= "<option value=77>Kuwaiti Dinar</option>\n";
230$estimated .= "<option value=78>Lao Kip</option>\n";
231$estimated .= "<option value=79>Latvian Lat</option>\n";
232$estimated .= "<option value=80>Lebanese Pound</option>\n";
233$estimated .= "<option value=81>Lesotho Maloti</option>\n";
234$estimated .= "<option value=82>Liberian Dollar</option>\n";
235$estimated .= "<option value=83>Libyan Dinar</option>\n";
236$estimated .= "<option value=84>Lithuanian Litas</option>\n";
237$estimated .= "<option value=85>Macao Patacas</option>\n";
238$estimated .= "<option value=86>Macedonian Denar</option>\n";
239$estimated .= "<option value=87>Madagascar Ariary</option>\n";
240$estimated .= "<option value=88>Malawi Kwacha</option>\n";
241$estimated .= "<option value=89>Malaysian Ringgit</option>\n";
242$estimated .= "<option value=90>Maldive Rufiyaa</option>\n";
243$estimated .= "<option value=91>Maltese Lira</option>\n";
244$estimated .= "<option value=92>Mauritanian Ouguiya</option>\n";
245$estimated .= "<option value=93>Mauritian Rupee</option>\n";
246$estimated .= "<option value=94>Mexican Peso</option>\n";
247$estimated .= "<option value=95>Moldova Leu</option>\n";
248$estimated .= "<option value=96>Mongolian Tugrik</option>\n";
249$estimated .= "<option value=97>Moroccan Dirham</option>\n";
250$estimated .= "<option value=98>Mozambique Metical</option>\n";
251$estimated .= "<option value=99>Myanmar Kyat</option>\n";
252$estimated .= "<option value=100>Namibia Dollar</option>\n";
253$estimated .= "<option value=101>Nepalese Rupee</option>\n";
254$estimated .= "<option value=102>New Zealand Dollar</option>\n";
255$estimated .= "<option value=103>Nicaraguan Cordoba Oro</option>\n";
256$estimated .= "<option value=104>Nigerian Naira</option>\n";
257$estimated .= "<option value=105>North Korean Won</option>\n";
258$estimated .= "<option value=106>Norwegian Kroner</option>\n";
259$estimated .= "<option value=107>Omani Rial</option>\n";
260$estimated .= "<option value=108>Pakistan Rupee</option>\n";
261$estimated .= "<option value=109>Panamanian Balboa</option>\n";
262$estimated .= "<option value=110>Papua New Guinea Kina</option>\n";
263$estimated .= "<option value=111>Paraguay Guarani</option>\n";
264$estimated .= "<option value=112>Peruvian Nuevo Sol</option>\n";
265$estimated .= "<option value=113>Philippine Peso</option>\n";
266$estimated .= "<option value=114>Polish Zloty</option>\n";
267$estimated .= "<option value=115>Portuguese Escudo</option>\n";
268$estimated .= "<option value=116>Qatari Rial</option>\n";
269$estimated .= "<option value=117>Romanian Leu</option>\n";
270$estimated .= "<option value=118>Russian Ruble</option>\n";
271$estimated .= "<option value=119>Rwandan Franc</option>\n";
272$estimated .= "<option value=120>Saint Helena Pound</option>\n";
273$estimated .= "<option value=121>Sao Tome/Principe Dobra</option>\n";
274$estimated .= "<option value=122>Saudi Riyal</option>\n";
275$estimated .= "<option value=123>Serbia Dinar</option>\n";
276$estimated .= "<option value=124>Seychelles Rupee</option>\n";
277$estimated .= "<option value=125>Sierra Leone Leone</option>\n";
278$estimated .= "<option value=126>Singapore Dollar</option>\n";
279$estimated .= "<option value=127>Slovak Koruna</option>\n";
280$estimated .= "<option value=128>Slovenian Tolar</option>\n";
281$estimated .= "<option value=129>Solomon Dollar</option>\n";
282$estimated .= "<option value=130>Somalia Shiling</option>\n";
283$estimated .= "<option value=131>Somoa Tala</option>\n";
284$estimated .= "<option value=132>South African Rand</option>\n";
285$estimated .= "<option value=133>South Korean Won</option>\n";
286$estimated .= "<option value=134>Sri Lanka Rupee</option>\n";
287$estimated .= "<option value=135>Sudanese Dinar</option>\n";
288$estimated .= "<option value=136>Suriname Dollar</option>\n";
289$estimated .= "<option value=137>Swaziland Emalangeni</option>\n";
290$estimated .= "<option value=138>Swedish Krona</option>\n";
291$estimated .= "<option value=139>Swiss Franc</option>\n";
292$estimated .= "<option value=140>Syrian Pound</option>\n";
293$estimated .= "<option value=141>Taiwan Dollar</option>\n";
294$estimated .= "<option value=142>Tanzania Shiling</option>\n";
295$estimated .= "<option value=143>Thai Baht</option>\n";
296$estimated .= "<option value=144>Tonga Pa\anga</option>\n";
297$estimated .= "<option value=145>Trinidad Dollar</option>\n";
298$estimated .= "<option value=146>Tunisia Dinar</option>\n";
299$estimated .= "<option value=147>Turkish Lira</option>\n";
300$estimated .= "<option value=148>Turkmenistan Manat</option>\n";
301$estimated .= "<option value=149>Uganda Shilling</option>\n";
302$estimated .= "<option value=150>Ukrainian Hryvnia</option>\n";
303$estimated .= "<option value=151>Uruguayan Peso</option>\n";
304$estimated .= "<option value=152>Utd. Arab Emir. Dirham</option>\n";
305$estimated .= "<option value=153>Uzbekistan Sum</option>\n";
306$estimated .= "<option value=154>Vanuatu Vatu</option>\n";
307$estimated .= "<option value=155>Venezuelan Bolivar</option>\n";
308$estimated .= "<option value=156>Vietnamese Dong</option>\n";
309$estimated .= "<option value=157>Yemen Rial</option>\n";
310$estimated .= "<option value=158>Zambia Kwacha</option>\n";
311$estimated .= "<option value=159>Zimbabwe Dollar</option>\n";
312$estimated .= "</select>\n";
313$estimated .= "<input name=\"outV\" value=\"0.00\" style=\"text-align: right; width: 80px;\" disabled=\"disabled\">\n";
314
315echo row2(tra("Amount you would like to donate"), $amount);
316echo row2(tra("Estimated value in"), $estimated);
317if ($user_id) {
318    $tmp_user_name = $user_id." (".$logged_in_user->name.")";
319    echo row2(tra("Anonymous donation")."<br><small>".tra("Select this if you dont want your name and account number displayed in
320donator lists.<br>If not checked, you will be recorded as user ID %1", $tmp_user_name)."</small>",
321        "<input type=\"checkbox\" name=\"anonymous\" id=\"anonymous\" value=\"1\"><label for=\"anonymous\">".tra("Yes")."</label>");
322} else {
323    echo row2(tra("Anonymous donation")."<br><small>".tra("To assign the donation with your user ID, please log in.")."</small>",
324        "<input type=\"checkbox\" name=\"anonymous\" id=\"anonymous\" value=\"1\" checked=\"checked\" disabled=\"disabled\">
325        <label for=\"anonymous\">".tra("Yes")."</label>");
326}
327echo row2("", "<input class=\"btn btn-primary\" type=\"submit\" value=\"".tra("Proceed")."\">");
328echo row1(tra("Donations are accepted through")."<br><img src=\"img/paypal_logo.png\" alt=\"PayPal\">");
329end_table();
330echo "</form>\n";
331
332page_tail();
333
334?>
335