From 1a3f4c90cbe5d3a28408887f1bbfcc9b5fd6e806 Mon Sep 17 00:00:00 2001 From: Peter Goodhall Date: Thu, 23 May 2024 15:33:48 +0100 Subject: [PATCH] Demo code for flags --- application/controllers/Debug.php | 11 + application/libraries/DxccFlag.php | 352 +++++++++++++++++++++++++++++ 2 files changed, 363 insertions(+) diff --git a/application/controllers/Debug.php b/application/controllers/Debug.php index 1d60cbd5..936f2e78 100644 --- a/application/controllers/Debug.php +++ b/application/controllers/Debug.php @@ -64,4 +64,15 @@ class Debug extends CI_Controller { return false; } + + public function flags() { + + // load library called DxccFlag + $this->load->library('DxccFlag'); + + // Call getISO function from DxccFlag library + $data['flags'] = $this->dxccflag->getISO('33'); + + print_r($data['flags']); + } } diff --git a/application/libraries/DxccFlag.php b/application/libraries/DxccFlag.php index b491482e..e8e06ae4 100644 --- a/application/libraries/DxccFlag.php +++ b/application/libraries/DxccFlag.php @@ -3,6 +3,349 @@ class DxccFlag { + // create an array + private $dxccCodetoISOArray = array( + 1 => 'CA', + 3 => 'AF', + 4 => 'MP', + 5 => 'AX', + 6 => 'US', + 7 => 'AL', + 9 => 'AS', + 10 => 'FR', + 11 => 'IN', + 12 => 'AI', + 13 => 'AQ', + 14 => 'AM', + 15 => 'RU', + 16 => 'NZ', + 17 => 'VE', + 18 => 'AZ', + 20 => 'US', + 21 => 'ES', + 22 => 'PW', + 24 => 'BV', + 27 => 'BY', + 29 => 'ES', + 31 => 'KI', + 32 => 'ES', + 33 => 'GB', + 34 => 'NZ', + 35 => 'CX', + 36 => 'FR', + 37 => 'CR', + 38 => 'CC', + 40 => 'GR', + 41 => 'FR', + 43 => 'PR', + 45 => 'GR', + 46 => 'MY', + 47 => 'CL', + 48 => 'KI', + 49 => 'GQ', + 50 => 'MX', + 51 => 'ER', + 52 => 'EE', + 53 => 'ET', + 54 => 'RU', + 56 => 'BR', + 60 => 'BS', + 61 => 'RU', + 62 => 'BB', + 63 => 'GF', + 64 => 'BM', + 65 => 'VG', + 66 => 'BZ', + 69 => 'KY', + 70 => 'CU', + 71 => 'EC', + 72 => 'DO', + 74 => 'SV', + 75 => 'GE', + 76 => 'GT', + 77 => 'GD', + 78 => 'HT', + 79 => 'GP', + 80 => 'HN', + 82 => 'JM', + 84 => 'MQ', + 85 => 'AN', + 86 => 'NI', + 88 => 'PA', + 89 => 'TC', + 90 => 'TT', + 91 => 'AW', + 94 => 'AG', + 95 => 'DM', + 96 => 'MS', + 97 => 'LC', + 98 => 'VC', + 99 => 'FR', + 100 => 'AR', + 103 => 'GU', + 104 => 'BO', + 105 => 'US', + 106 => 'GG', + 107 => 'GN', + 108 => 'BR', + 109 => 'GW', + 110 => 'US', + 111 => 'HM', + 112 => 'CL', + 114 => 'IM', + 116 => 'CO', + 117 => 'CH', + 118 => 'SJ', + 120 => 'EC', + 122 => 'JE', + 123 => 'US', + 124 => 'FR', + 125 => 'CL', + 126 => 'RU', + 129 => 'GY', + 130 => 'KZ', + 131 => 'FR', + 132 => 'PY', + 133 => 'NZ', + 134 => 'US', + 135 => 'KG', + 136 => 'PE', + 137 => 'KR', + 138 => 'US', + 140 => 'SR', + 141 => 'FK', + 142 => 'IN', + 143 => 'LA', + 144 => 'UY', + 145 => 'LV', + 146 => 'LT', + 147 => 'AU', + 148 => 'VE', + 149 => 'PT', + 150 => 'AU', + 151 => 'RU', + 152 => 'MO', + 153 => 'AU', + 157 => 'NR', + 158 => 'VU', + 159 => 'MV', + 160 => 'TO', + 161 => 'CO', + 162 => 'NC', + 163 => 'PG', + 165 => 'MU', + 166 => 'US', + 167 => 'SE', + 168 => 'MH', + 169 => 'YT', + 170 => 'NZ', + 171 => 'AU', + 172 => 'PN', + 173 => 'FM', + 174 => 'US', + 175 => 'PF', + 176 => 'FJ', + 177 => 'JP', + 179 => 'MD', + 180 => 'GR', + 181 => 'MZ', + 182 => 'US', + 185 => 'SB', + 187 => 'NE', + 188 => 'NU', + 189 => 'NF', + 190 => 'WS', + 191 => 'NZ', + 192 => 'JP', + 195 => 'GQ', + 197 => 'US', + 199 => 'NO', + 201 => 'ZA', + 202 => 'PR', + 203 => 'AD', + 204 => 'MX', + 205 => 'UK', + 206 => 'AT', + 207 => 'MU', + 209 => 'BE', + 211 => 'CA', + 212 => 'BG', + 213 => 'FR', + 214 => 'FR', + 215 => 'CY', + 216 => 'NI', + 217 => 'CL', + 219 => 'ST', + 221 => 'DK', + 222 => 'FO', + 223 => 'GB', + 224 => 'FI', + 225 => 'IT', + 227 => 'FR', + 230 => 'DE', + 232 => 'SO', + 233 => 'GI', + 234 => 'GS', + 235 => 'GS', + 236 => 'GR', + 237 => 'GL', + 238 => 'GB', + 239 => 'HU', + 240 => 'GS', + 241 => 'GB', + 242 => 'IS', + 245 => 'IE', + 246 => 'MT', + 247 => 'PH', + 248 => 'IT', + 249 => 'KN', + 250 => 'SH', + 251 => 'LI', + 252 => 'CA', + 253 => 'BR', + 254 => 'LU', + 256 => 'PT', + 257 => 'MT', + 259 => 'SJ', + 260 => 'MC', + 262 => 'TJ', + 263 => 'NL', + 265 => 'GB', + 266 => 'NO', + 269 => 'PL', + 270 => 'TK', + 272 => 'PT', + 273 => 'BR', + 274 => 'GB', + 275 => 'RO', + 276 => 'FR', + 277 => 'CA', + 278 => 'SM', + 279 => 'GB', + 280 => 'TM', + 281 => 'ES', + 282 => 'TV', + 283 => 'CY', + 284 => 'SE', + 285 => 'VI', + 286 => 'UG', + 287 => 'CH', + 288 => 'UA', + 289 => 'UN', + 291 => 'US', + 292 => 'UZ', + 293 => 'VN', + 294 => 'GB', + 295 => 'VA', + 296 => 'RS', + 297 => 'US', + 298 => 'WF', + 299 => 'MY', + 301 => 'KI', + 302 => 'EH', + 303 => 'AU', + 304 => 'BH', + 305 => 'BD', + 306 => 'BT', + 308 => 'CR', + 309 => 'MM', + 312 => 'KH', + 315 => 'LK', + 318 => 'CN', + 321 => 'HK', + 324 => 'IN', + 327 => 'ID', + 330 => 'IR', + 333 => 'IQ', + 336 => 'IL', + 339 => 'JP', + 342 => 'JO', + 344 => 'KP', + 345 => 'BN', + 348 => 'KW', + 354 => 'LB', + 363 => 'MN', + 369 => 'NP', + 370 => 'OM', + 372 => 'PK', + 375 => 'PH', + 376 => 'QA', + 378 => 'SA', + 379 => 'SC', + 381 => 'SG', + 382 => 'DJ', + 384 => 'SY', + 386 => 'TW', + 387 => 'TH', + 390 => 'TR', + 391 => 'AE', + 400 => 'DZ', + 401 => 'AO', + 402 => 'BW', + 404 => 'BI', + 406 => 'CM', + 408 => 'CF', + 409 => 'CV', + 410 => 'TD', + 411 => 'KM', + 412 => 'CG', + 414 => 'CD', + 416 => 'BJ', + 420 => 'GA', + 422 => 'GM', + 424 => 'GH', + 428 => 'CI', + 430 => 'KE', + 432 => 'LS', + 434 => 'LR', + 436 => 'LY', + 438 => 'MG', + 440 => 'MW', + 442 => 'ML', + 444 => 'MR', + 446 => 'MA', + 450 => 'NG', + 452 => 'ZW', + 453 => 'RE', + 454 => 'RW', + 456 => 'SN', + 458 => 'SL', + 460 => 'FJ', + 462 => 'ZA', + 464 => 'NA', + 466 => 'SD', + 468 => 'SZ', + 470 => 'TZ', + 474 => 'TN', + 478 => 'EG', + 480 => 'BF', + 482 => 'ZM', + 483 => 'TG', + 489 => 'FJ', + 490 => 'KI', + 492 => 'YE', + 497 => 'HR', + 499 => 'SI', + 501 => 'BA', + 502 => 'MK', + 503 => 'CZ', + 504 => 'SK', + 505 => 'TW', + 507 => 'SB', + 508 => 'PF', + 509 => 'FR', + 510 => 'PS', + 511 => 'TL', + 512 => 'GB', + 513 => 'PN', + 514 => 'ME', + 515 => 'US', + 517 => 'AN', + 519 => 'AN', + 521 => 'SS', + 1378 => 'SA' + ); + private $dxccFlags = array( '0' => "", // DXCC NONE '1' => "\u{1F1E8}\u{1F1E6}", // CANADA @@ -417,4 +760,13 @@ class DxccFlag return $this->dxccFlags[$dxcc]; } } + + public function getISO($dxccCode) { + // Check if DXCC Code is in dxccCodetoISOArray + if (!isset($this->dxccCodetoISOArray[$dxccCode])) { + return null; + } else { + return $this->dxccCodetoISOArray[$dxccCode]; + } + } }