Browse Source

mostly complete aca, cma, was, waz, dxcc, etc.

master
Fabian Kurz 2 years ago
parent
commit
af1bf359ab
  1. 34
      api.php
  2. 404
      dxccs.php
  3. 175
      functions.php

34
api.php

@ -0,0 +1,34 @@
<?
session_start();
include("functions.php");
$bands = array("160", "80", "60", "40", "30", "20", "17", "15", "12", "10", "6", "2", "all");
switch ($_GET['action']) {
case 'aca':
echo aca($_SESSION['callsign']);
break;
case 'cma':
echo cma($_SESSION['callsign']);
break;
case 'was':
$band = $_GET['band'];
if (in_array($band, $bands)) {
echo was($_SESSION['callsign'], $band);
}
break;
case 'waz':
$band = $_GET['band'];
if (in_array($band, $bands)) {
echo waz($_SESSION['callsign'], $band);
}
break;
case 'dxcc':
$band = $_GET['band'];
if (in_array($band, $bands)) {
echo dxcc($_SESSION['callsign'], $band);
}
break;
}
?>

404
dxccs.php

@ -0,0 +1,404 @@
<?
$dxcc = array(1=>"CANADA",
2=>"ABU AIL IS.",
3=>"AFGHANISTAN",
4=>"AGALEGA & ST. BRANDON IS.",
5=>"ALAND IS.",
6=>"ALASKA",
7=>"ALBANIA",
8=>"ALDABRA",
9=>"AMERICAN SAMOA",
10=>"AMSTERDAM & ST. PAUL IS.",
11=>"ANDAMAN & NICOBAR IS.",
12=>"ANGUILLA",
13=>"ANTARCTICA",
14=>"ARMENIA",
15=>"ASIATIC RUSSIA",
16=>"NEW ZEALAND SUBANTARCTIC ISLANDS",
17=>"AVES I.",
18=>"AZERBAIJAN",
19=>"BAJO NUEVO",
20=>"BAKER & HOWLAND IS.",
21=>"BALEARIC IS.",
22=>"PALAU",
23=>"BLENHEIM REEF",
24=>"BOUVET",
25=>"BRITISH NORTH BORNEO",
26=>"BRITISH SOMALILAND",
27=>"BELARUS",
28=>"CANAL ZONE",
29=>"CANARY IS.",
30=>"CELEBE & MOLUCCA IS.",
31=>"C. KIRIBATI (BRITISH PHOENIX IS.)",
32=>"CEUTA & MELILLA",
33=>"CHAGOS IS.",
34=>"CHATHAM IS.",
35=>"CHRISTMAS I.",
36=>"CLIPPERTON I.",
37=>"COCOS I.",
38=>"COCOS (KEELING) IS.",
39=>"COMOROS",
40=>"CRETE",
41=>"CROZET I.",
42=>"DAMAO, DIU",
43=>"DESECHEO I.",
44=>"DESROCHES",
45=>"DODECANESE",
46=>"EAST MALAYSIA",
47=>"EASTER I.",
48=>"E. KIRIBATI (LINE IS.)",
49=>"EQUATORIAL GUINEA",
50=>"MEXICO",
51=>"ERITREA",
52=>"ESTONIA",
53=>"ETHIOPIA",
54=>"EUROPEAN RUSSIA",
55=>"FARQUHAR",
56=>"FERNANDO DE NORONHA",
57=>"FRENCH EQUATORIAL AFRICA",
58=>"FRENCH INDO-CHINA",
59=>"FRENCH WEST AFRICA",
60=>"BAHAMAS",
61=>"FRANZ JOSEF LAND",
62=>"BARBADOS",
63=>"FRENCH GUIANA",
64=>"BERMUDA",
65=>"BRITISH VIRGIN IS.",
66=>"BELIZE",
67=>"FRENCH INDIA",
68=>"KUWAIT/SAUDI ARABIA NEUTRAL ZONE",
69=>"CAYMAN IS.",
70=>"CUBA",
71=>"GALAPAGOS IS.",
72=>"DOMINICAN REPUBLIC",
74=>"EL SALVADOR",
75=>"GEORGIA",
76=>"GUATEMALA",
77=>"GRENADA",
78=>"HAITI",
79=>"GUADELOUPE",
80=>"HONDURAS",
81=>"GERMANY",
82=>"JAMAICA",
84=>"MARTINIQUE",
85=>"BONAIRE, CURACAO",
86=>"NICARAGUA",
88=>"PANAMA",
89=>"TURKS & CAICOS IS.",
90=>"TRINIDAD & TOBAGO",
91=>"ARUBA",
93=>"GEYSER REEF",
94=>"ANTIGUA & BARBUDA",
95=>"DOMINICA",
96=>"MONTSERRAT",
97=>"ST. LUCIA",
98=>"ST. VINCENT",
99=>"GLORIOSO IS.",
100=>"ARGENTINA",
101=>"GOA",
102=>"GOLD COAST, TOGOLAND",
103=>"GUAM",
104=>"BOLIVIA",
105=>"GUANTANAMO BAY",
106=>"GUERNSEY",
107=>"GUINEA",
108=>"BRAZIL",
109=>"GUINEA-BISSAU",
110=>"HAWAII",
111=>"HEARD I.",
112=>"CHILE",
113=>"IFNI",
114=>"ISLE OF MAN",
115=>"ITALIAN SOMALILAND",
116=>"COLOMBIA",
117=>"ITU HQ",
118=>"JAN MAYEN",
119=>"JAVA",
120=>"ECUADOR",
122=>"JERSEY",
123=>"JOHNSTON I.",
124=>"JUAN DE NOVA, EUROPA",
125=>"JUAN FERNANDEZ IS.",
126=>"KALININGRAD",
127=>"KAMARAN IS.",
128=>"KARELO-FINNISH REPUBLIC",
129=>"GUYANA",
130=>"KAZAKHSTAN",
131=>"KERGUELEN IS.",
132=>"PARAGUAY",
133=>"KERMADEC IS.",
134=>"KINGMAN REEF",
135=>"KYRGYZSTAN",
136=>"PERU",
137=>"REPUBLIC OF KOREA",
138=>"KURE I.",
139=>"KURIA MURIA I.",
140=>"SURINAME",
141=>"FALKLAND IS.",
142=>"LAKSHADWEEP IS.",
143=>"LAOS",
144=>"URUGUAY",
145=>"LATVIA",
146=>"LITHUANIA",
147=>"LORD HOWE I.",
148=>"VENEZUELA",
149=>"AZORES",
150=>"AUSTRALIA",
151=>"MALYJ VYSOTSKIJ I.",
152=>"MACAO",
153=>"MACQUARIE I.",
154=>"YEMEN ARAB REPUBLIC",
155=>"MALAYA",
157=>"NAURU",
158=>"VANUATU",
159=>"MALDIVES",
160=>"TONGA",
161=>"MALPELO I.",
162=>"NEW CALEDONIA",
163=>"PAPUA NEW GUINEA",
164=>"MANCHURIA",
165=>"MAURITIUS",
166=>"MARIANA IS.",
167=>"MARKET REEF",
168=>"MARSHALL IS.",
169=>"MAYOTTE",
170=>"NEW ZEALAND",
171=>"MELLISH REEF",
172=>"PITCAIRN I.",
173=>"MICRONESIA",
174=>"MIDWAY I.",
175=>"FRENCH POLYNESIA",
176=>"FIJI",
177=>"MINAMI TORISHIMA",
178=>"MINERVA REEF",
179=>"MOLDOVA",
180=>"MOUNT ATHOS",
181=>"MOZAMBIQUE",
182=>"NAVASSA I.",
183=>"NETHERLANDS BORNEO",
184=>"NETHERLANDS NEW GUINEA",
185=>"SOLOMON IS.",
186=>"NEWFOUNDLAND, LABRADOR",
187=>"NIGER",
188=>"NIUE",
189=>"NORFOLK I.",
190=>"SAMOA",
191=>"NORTH COOK IS.",
192=>"OGASAWARA",
193=>"OKINAWA (RYUKYU IS.)",
194=>"OKINO TORI-SHIMA",
195=>"ANNOBON I.",
196=>"PALESTINE",
197=>"PALMYRA & JARVIS IS.",
198=>"PAPUA TERRITORY",
199=>"PETER 1 I.",
200=>"PORTUGUESE TIMOR",
201=>"PRINCE EDWARD & MARION IS.",
202=>"PUERTO RICO",
203=>"ANDORRA",
204=>"REVILLAGIGEDO",
205=>"ASCENSION I.",
206=>"AUSTRIA",
207=>"RODRIGUEZ I.",
208=>"RUANDA-URUNDI",
209=>"BELGIUM",
210=>"SAAR",
211=>"SABLE I.",
212=>"BULGARIA",
213=>"SAINT MARTIN",
214=>"CORSICA",
215=>"CYPRUS",
216=>"SAN ANDRES & PROVIDENCIA",
217=>"SAN FELIX & SAN AMBROSIO",
218=>"CZECHOSLOVAKIA",
219=>"SAO TOME & PRINCIPE",
220=>"SARAWAK",
221=>"DENMARK",
222=>"FAROE IS.",
223=>"ENGLAND",
224=>"FINLAND",
225=>"SARDINIA",
226=>"SAUDI ARABIA/IRAQ NEUTRAL ZONE",
227=>"FRANCE",
228=>"SERRANA BANK & RONCADOR CAY",
229=>"GERMAN DEMOCRATIC REPUBLIC",
230=>"FEDERAL REPUBLIC OF GERMANY",
231=>"SIKKIM",
232=>"SOMALIA",
233=>"GIBRALTAR",
234=>"SOUTH COOK IS.",
235=>"SOUTH GEORGIA I.",
236=>"GREECE",
237=>"GREENLAND",
238=>"SOUTH ORKNEY IS.",
239=>"HUNGARY",
240=>"SOUTH SANDWICH IS.",
241=>"SOUTH SHETLAND IS.",
242=>"ICELAND",
243=>"PEOPLE'S DEMOCRATIC REP. OF YEMEN",
244=>"SOUTHERN SUDAN",
245=>"IRELAND",
246=>"SOVEREIGN MILITARY ORDER OF MALTA",
247=>"SPRATLY IS.",
248=>"ITALY",
249=>"ST. KITTS & NEVIS",
250=>"ST. HELENA",
251=>"LIECHTENSTEIN",
252=>"ST. PAUL I.",
253=>"ST. PETER & ST. PAUL ROCKS",
254=>"LUXEMBOURG",
255=>"ST. MAARTEN, SABA, ST. EUSTATIUS",
256=>"MADEIRA IS.",
257=>"MALTA",
258=>"SUMATRA",
259=>"SVALBARD",
260=>"MONACO",
261=>"SWAN IS.",
262=>"TAJIKISTAN",
263=>"NETHERLANDS",
264=>"TANGIER",
265=>"NORTHERN IRELAND",
266=>"NORWAY",
267=>"TERRITORY OF NEW GUINEA",
268=>"TIBET",
269=>"POLAND",
270=>"TOKELAU IS.",
271=>"TRIESTE",
272=>"PORTUGAL",
273=>"TRINDADE & MARTIM VAZ IS.",
274=>"TRISTAN DA CUNHA & GOUGH I.",
275=>"ROMANIA",
276=>"TROMELIN I.",
277=>"ST. PIERRE & MIQUELON",
278=>"SAN MARINO",
279=>"SCOTLAND",
280=>"TURKMENISTAN",
281=>"SPAIN",
282=>"TUVALU",
283=>"UK SOVEREIGN BASE AREAS ON CYPRUS",
284=>"SWEDEN",
285=>"VIRGIN IS.",
286=>"UGANDA",
287=>"SWITZERLAND",
288=>"UKRAINE",
289=>"UNITED NATIONS HQ",
291=>"UNITED STATES OF AMERICA",
292=>"UZBEKISTAN",
293=>"VIET NAM",
294=>"WALES",
295=>"VATICAN",
296=>"SERBIA",
297=>"WAKE I.",
298=>"WALLIS & FUTUNA IS.",
299=>"WEST MALAYSIA",
301=>"W. KIRIBATI (GILBERT IS. )",
302=>"WESTERN SAHARA",
303=>"WILLIS I.",
304=>"BAHRAIN",
305=>"BANGLADESH",
306=>"BHUTAN",
307=>"ZANZIBAR",
308=>"COSTA RICA",
309=>"MYANMAR",
312=>"CAMBODIA",
315=>"SRI LANKA",
318=>"CHINA",
321=>"HONG KONG",
324=>"INDIA",
327=>"INDONESIA",
330=>"IRAN",
333=>"IRAQ",
336=>"ISRAEL",
339=>"JAPAN",
342=>"JORDAN",
344=>"DEMOCRATIC PEOPLE'S REP. OF KOREA",
345=>"BRUNEI DARUSSALAM",
348=>"KUWAIT",
354=>"LEBANON",
363=>"MONGOLIA",
369=>"NEPAL",
370=>"OMAN",
372=>"PAKISTAN",
375=>"PHILIPPINES",
376=>"QATAR",
378=>"SAUDI ARABIA",
379=>"SEYCHELLES",
381=>"SINGAPORE",
382=>"DJIBOUTI",
384=>"SYRIA",
386=>"TAIWAN",
387=>"THAILAND",
390=>"TURKEY",
391=>"UNITED ARAB EMIRATES",
400=>"ALGERIA",
401=>"ANGOLA",
402=>"BOTSWANA",
404=>"BURUNDI",
406=>"CAMEROON",
408=>"CENTRAL AFRICA",
409=>"CAPE VERDE",
410=>"CHAD",
411=>"COMOROS",
412=>"REPUBLIC OF THE CONGO",
414=>"DEMOCRATIC REPUBLIC OF THE CONGO",
416=>"BENIN",
420=>"GABON",
422=>"THE GAMBIA",
424=>"GHANA",
428=>"COTE D'IVOIRE",
430=>"KENYA",
432=>"LESOTHO",
434=>"LIBERIA",
436=>"LIBYA",
438=>"MADAGASCAR",
440=>"MALAWI",
442=>"MALI",
444=>"MAURITANIA",
446=>"MOROCCO",
450=>"NIGERIA",
452=>"ZIMBABWE",
453=>"REUNION I.",
454=>"RWANDA",
456=>"SENEGAL",
458=>"SIERRA LEONE",
460=>"ROTUMA I.",
462=>"SOUTH AFRICA",
464=>"NAMIBIA",
466=>"SUDAN",
468=>"SWAZILAND",
470=>"TANZANIA",
474=>"TUNISIA",
478=>"EGYPT",
480=>"BURKINA FASO",
482=>"ZAMBIA",
483=>"TOGO",
488=>"WALVIS BAY",
489=>"CONWAY REEF",
490=>"BANABA I. (OCEAN I.)",
492=>"YEMEN",
493=>"PENGUIN IS.",
497=>"CROATIA",
499=>"SLOVENIA",
501=>"BOSNIA-HERZEGOVINA",
502=>"MACEDONIA",
503=>"CZECH REPUBLIC",
504=>"SLOVAK REPUBLIC",
505=>"PRATAS I.",
506=>"SCARBOROUGH REEF",
507=>"TEMOTU PROVINCE",
508=>"AUSTRAL I.",
509=>"MARQUESAS IS.",
510=>"PALESTINE",
511=>"TIMOR-LESTE",
512=>"CHESTERFIELD IS.",
513=>"DUCIE I.",
514=>"MONTENEGRO",
515=>"SWAINS I.",
516=>"SAINT BARTHELEMY",
517=>"CURACAO",
518=>"ST MAARTEN",
519=>"SABA & ST. EUSTATIUS",
520=>"BONAIRE",
521=>"SOUTH SUDAN (REPUBLIC OF)",
522=>"REPUBLIC OF KOSOVO",
);

175
functions.php

@ -1,10 +1,167 @@
<?php
include_once("db.php");
$states = array("AK"=>1, "HI"=>1, "CT"=>1, "ME"=>1, "MA"=>1, "NH"=>1, "RI"=>1, "VT"=>1, "NJ"=>1, "NY"=>1, "DE"=>1, "MD"=>1, "PA"=>1, "AL"=>1, "FL"=>1, "GA"=>1, "KY"=>1, "NC"=>1, "SC"=>1, "TN"=>1, "VA"=>1, "AR"=>1, "LA"=>1, "MS"=>1, "NM"=>1, "OK"=>1, "TX"=>1, "CA"=>1, "AZ"=>1, "ID"=>1, "MT"=>1, "NV"=>1, "OR"=>1, "UT"=>1, "WA"=>1, "WY"=>1, "MI"=>1, "OH"=>1, "WV"=>1, "IL"=>1, "IN"=>1, "WI"=>1, "CO"=>1, "IA"=>1, "KS"=>1, "MN"=>1, "MO"=>1, "NE"=>1, "ND"=>1, "SD"=>1);
function stats($c) {
global $db;
# ACA
$q = mysqli_query($db, "SELECT count(distinct(`nr`)) from cwops_log where `mycall`='$c' and year=YEAR(CURDATE())");
$r = mysqli_fetch_row($q);
$aca = $r[0];
$q = mysqli_query($db, "SELECT count(distinct `nr`, `band`) from cwops_log where `mycall`='$c'");
$r = mysqli_fetch_row($q);
$cma = $r[0];
$q = mysqli_query($db, "SELECT count(distinct(`was`)) from cwops_log where `mycall`='$c'");
$r = mysqli_fetch_row($q);
$was = $r[0]-1; # empty state
$q = mysqli_query($db, "SELECT count(distinct(`dxcc`)) from cwops_log where `mycall`='$c'");
$r = mysqli_fetch_row($q);
$dxcc = $r[0];
$q = mysqli_query($db, "SELECT count(distinct(`waz`)) from cwops_log where `mycall`='$c'");
$r = mysqli_fetch_row($q);
$waz = $r[0];
?>
<table>
<tr><th>Award</th><th>Score</th><th>Details</th></tr>
<tr><td>ACA</td> <td><?=$aca?></td> <td><?=award_details('aca', 0);?></td></tr>
<tr><td>CMA</td> <td><?=$cma?></td> <td><?=award_details('cma', 0);?></td></tr>
<tr><td>WAS</td> <td><?=$was?></td> <td><?=award_details('was', 1);?></td></tr>
<tr><td>DXCC</td><td><?=$dxcc?></td><td><?=award_details('dxcc', 1);?></td></tr>
<tr><td>WAZ</td> <td><?=$waz?></td> <td><?=award_details('waz', 1);?></td></tr>
</table>
<div id="details"></div>
<script>
function details(t) {
var band = document.getElementById('band'+t).value;
console.log('Details for ' + t + ' on ' + band);
}
</script>
<?
}
function award_details($t, $b) {
$ret = "<button id='$t' onClick='javascript:details(this.id);'>Show details</button>";
if ($b) {
$ret .= "<select name=\"band\" id=\"band$t\" size=1>
<option>all</option>
<option>160</option>
<option>80</option>
<option>60</option>
<option>40</option>
<option>30</option>
<option>20</option>
<option>17</option>
<option>15</option>
<option>12</option>
<option>10</option>
<option>6</option>
<option>2</option></select>";
}
return $ret;
}
function aca($c) {
global $db;
$ret = "";
$q = mysqli_query($db, "SELECT `nr`, hiscall, date, band from cwops_log where `mycall`='$c' and year=YEAR(CURDATE()) group by `nr`");
if(!$q) {
echo mysqli_error($db);
}
$cnt = 1;
$ret .= "<table><tr><th>Count</th><th>CWops</th><th>Call</th><th>Date</th><th>Band</th></tr>\n";
while ($r = mysqli_fetch_row($q)) {
$ret .= "<tr><td>".$cnt++."</td><td>".$r[0]."</td><td>".$r[1]."</td><td>".$r[2]."</td><td>".$r[3]."</td></tr>\n";
}
$ret .= "</table>";
return $ret;
}
function was($c, $b) {
global $db;
global $states;
if ($b != "all") {
$band = " and band=$b ";
}
$q = mysqli_query($db, "SELECT `was`, `nr`, hiscall, date, band from cwops_log where `mycall`='$c' and LENGTH(`was`) = 2 $band group by `was`");
if(!$q) {
echo mysqli_error($db);
}
$states_needed = $states;
$cnt = 1;
$ret = "<table><tr><th>Count</th><th>State</th><th>CWops</th><th>Call</th><th>Date</th><th>Band</th></tr>\n";
while ($r = mysqli_fetch_row($q)) {
$ret .= "<tr><td>".$cnt++."</td><td>".$r[0]."</td><td>".$r[1]."</td><td>".$r[2]."</td><td>".$r[3]."</td><td>".$r[4]."</td></tr>\n";
unset($states_needed[$r[0]]);
}
$ret .= "</table>";
$ret .= "<p>Needed: ".implode(", ", array_keys($states_needed))."</p>";
return $ret;
}
function waz($c, $b) {
global $db;
$ret = "";
if ($b != "all") {
$band = " and band=$b ";
}
$q = mysqli_query($db, "SELECT `waz`, `nr`, hiscall, date, band from cwops_log where `mycall`='$c' and waz > 0 $band group by `waz`");
if(!$q) {
echo mysqli_error($db);
}
$cnt = 1;
$ret .= "<table><tr><th>Count</th><th>Zone</th><th>CWops</th><th>Call</th><th>Date</th><th>Band</th></tr>\n";
while ($r = mysqli_fetch_row($q)) {
$ret .= "<tr><td>".$cnt++."</td><td>".$r[0]."</td><td>".$r[1]."</td><td>".$r[2]."</td><td>".$r[3]."</td><td>".$r[4]."</td></tr>\n";
}
$ret .= "</table>";
return $ret;
}
function dxcc($c, $b) {
global $db;
include("dxccs.php");
$ret = "";
if ($b != "all") {
$band = " and band=$b ";
}
$q = mysqli_query($db, "SELECT `dxcc`, `nr`, hiscall, date, band from cwops_log where `mycall`='$c' and dxcc > 0 $band group by `dxcc`");
if(!$q) {
echo mysqli_error($db);
}
$cnt = 1;
$ret .= "<table><tr><th>Count</th><th>DXCC</th><th>CWops</th><th>Call</th><th>Date</th><th>Band</th></tr>\n";
while ($r = mysqli_fetch_row($q)) {
$ret .= "<tr><td>".$cnt++."</td><td>".$dxcc[$r[0]]." (".$r[0].")</td><td>".$r[1]."</td><td>".$r[2]."</td><td>".$r[3]."</td><td>".$r[4]."</td></tr>\n";
}
$ret .= "</table>";
return $ret;
}
# import an ADIF file to the log of $callsign
#
@ -56,6 +213,9 @@ function parse_adif($adif, $members) {
# make hash table for quicker member lookup
$mh = array();
foreach ($members as $m) {
# fix date
$m['joined'] = preg_replace('/-/','', $m['joined']);
$m['left'] = preg_replace('/-/','', $m['left']);
$mh[$m["callsign"]] = $m;
}
@ -240,8 +400,11 @@ function filter_qsos ($qsos, $callsign) {
# ACA: New QSO with this member this year?
function new_aca($qso, $c) {
global $db;
if (substr($qso['date'], 0, 4) != "2019")
return false;
$query = "SELECT count(*) from cwops_log where mycall='$c' and nr=".$qso['nr']." and year=YEAR(CURDATE())";
error_log($query);
$q = mysqli_query($db, $query);
$r = mysqli_fetch_row($q);
return ($r[0] == 0);
@ -320,14 +483,10 @@ function get_log ($call) {
return $out;
}
#import(file_get_contents("dj1yfk.adi"), "DJ1YFK");
import(file_get_contents("dj1yfk.adi"), "y");
$time = microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"];
echo "time: $time\n";
#$time = microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"];
#echo "time: $time\n";
?>

Loading…
Cancel
Save