Issues (2756)

includes/functions-geo.php (118 issues)

1
<?php
2
/**
3
 * Function relative to the geolocation functions (ip <-> country <-> flags), currently
4
 * tied to Maxmind's GeoIP but this should evolve to become more pluggable
5
 */
6
7
/**
8
 * Converts an IP to a 2 letter country code, using GeoIP database if available in includes/geo/
9
 *
10
 * @since 1.4
11
 * @param string $ip      IP or, if empty string, will be current user IP
12
 * @param string $default Default string to return if IP doesn't resolve to a country (malformed, private IP...)
0 ignored issues
show
This line exceeds maximum limit of 100 characters; contains 112 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
13
 * @return string 2 letter country code (eg 'US') or $default
14
 */
15
function yourls_geo_ip_to_countrycode( $ip = '', $default = '' ) {
16
    // Allow plugins to short-circuit the Geo IP API
17 10
    $location = yourls_apply_filter( 'shunt_geo_ip_to_countrycode', false, $ip, $default ); // at this point $ip can be '', check if your plugin hooks in here
0 ignored issues
show
This line exceeds maximum limit of 100 characters; contains 158 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
18 10
    if ( false !== $location ) {
19
        return $location;
20
    }
21
22 10
    if ( yourls_apply_filter( 'geo_use_cloudflare', true )
23 10
         && !empty( $_SERVER[ 'HTTP_CF_IPCOUNTRY' ] ) && preg_match( '/^[A-Z]{2}$/', $_SERVER[ 'HTTP_CF_IPCOUNTRY' ] ) ) {
0 ignored issues
show
This line exceeds maximum limit of 100 characters; contains 122 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
24
        return $_SERVER[ 'HTTP_CF_IPCOUNTRY' ];
25
    }
26
27 10
    if ( empty( $ip ) ) {
28
        $ip = yourls_get_IP();
29
    }
30
31
    // Allow plugins to stick to YOURLS internals but provide another DB
32 10
    $db = yourls_apply_filter( 'geo_ip_path_to_db', YOURLS_INC.'/geo/GeoLite2-Country.mmdb' );
33 10
    if ( !is_readable( $db ) ) {
34
        return $default;
35
    }
36
37
    try {
38 10
        $reader = new \GeoIp2\Database\Reader( $db );
39 10
        $record = $reader->country( $ip );
40 6
        $location = $record->country->isoCode; // eg 'US'
41
    }
42 4
    catch ( \Exception $e ) {
43
        /*
44
        Unused for now, Exception and $e->getMessage() can be one of :
0 ignored issues
show
First line of comment not aligned correctly; expected 12 spaces but found 8
Loading history...
45
46
        - Exception: \GeoIp2\Exception\AddressNotFoundException
0 ignored issues
show
Comment line indented incorrectly; expected at least 12 spaces but found 8
Loading history...
47
          When: valid IP not found
0 ignored issues
show
Comment line indented incorrectly; expected at least 12 spaces but found 10
Loading history...
48
          Error message: "The address 10.0.0.30 is not in the database"
0 ignored issues
show
Comment line indented incorrectly; expected at least 12 spaces but found 10
Loading history...
49
50
        - Exception: \InvalidArgumentException
0 ignored issues
show
Comment line indented incorrectly; expected at least 12 spaces but found 8
Loading history...
51
          When: IP is not valid, or DB not readable
0 ignored issues
show
Comment line indented incorrectly; expected at least 12 spaces but found 10
Loading history...
52
          Error message: "The value "10.0.0.300" is not a valid IP address", "The file "/path/to/GeoLite2-Country.mmdb" does not exist or is not readable"
0 ignored issues
show
This line exceeds maximum limit of 100 characters; contains 154 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
Comment line indented incorrectly; expected at least 12 spaces but found 10
Loading history...
53
54
        - Exception: \MaxMind\Db\Reader\InvalidDatabaseException
0 ignored issues
show
Comment line indented incorrectly; expected at least 12 spaces but found 8
Loading history...
55
          When: DB is readable but is corrupt or invalid
0 ignored issues
show
Comment line indented incorrectly; expected at least 12 spaces but found 10
Loading history...
56
          Error message: "The MaxMind DB file's search tree is corrupt"
0 ignored issues
show
Comment line indented incorrectly; expected at least 12 spaces but found 10
Loading history...
57
58
        - or obviously \Exception for any other error (?)
0 ignored issues
show
Comment line indented incorrectly; expected at least 12 spaces but found 8
Loading history...
59
        */
0 ignored issues
show
Empty line required after block comment
Loading history...
60
    }
61
62 10
    return yourls_apply_filter( 'geo_ip_to_countrycode', empty( $location ) ? $default : $location, $ip, $default );
0 ignored issues
show
This line exceeds maximum limit of 100 characters; contains 116 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
63
}
64
65
/**
66
 * Converts a 2 letter country code to long name (ie AU -> Australia)
67
 *
68
 * This associative array is the one used by MaxMind internal functions, it may differ from other lists (eg "A1" does
0 ignored issues
show
This line exceeds maximum limit of 100 characters; contains 117 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
69
 * not universally stand for "Anon proxy")
70
 *
71
 * @since 1.4
72
 * @param string $code 2 letter country code, eg 'FR'
73
 * @return string Country long name (eg 'France') or an empty string if not found
74
 */
75
function yourls_geo_countrycode_to_countryname( $code ) {
76
    // Allow plugins to short-circuit the function
77 4
    $country = yourls_apply_filter( 'shunt_geo_countrycode_to_countryname', false, $code );
78 4
    if ( false !== $country ) {
79
        return $country;
80
    }
81
82
    // Weeeeeeeeeeee
83
    $countries = [
84 4
        'A1' => 'Anonymous Proxy', 'A2' => 'Satellite Provider', 'AD' => 'Andorra', 'AE' => 'United Arab Emirates', 'AF' => 'Afghanistan',
0 ignored issues
show
Each index in a multi-line array must be on a new line
Loading history...
This line exceeds maximum limit of 100 characters; contains 138 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
85
        'AG' => 'Antigua and Barbuda', 'AI' => 'Anguilla', 'AL' => 'Albania', 'AM' => 'Armenia', 'AO' => 'Angola',
0 ignored issues
show
Each index in a multi-line array must be on a new line
Loading history...
This line exceeds maximum limit of 100 characters; contains 114 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
86
        'AP' => 'Asia/Pacific Region', 'AQ' => 'Antarctica', 'AR' => 'Argentina', 'AS' => 'American Samoa', 'AT' => 'Austria',
0 ignored issues
show
Each index in a multi-line array must be on a new line
Loading history...
This line exceeds maximum limit of 100 characters; contains 126 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
87
        'AU' => 'Australia', 'AW' => 'Aruba', 'AX' => 'Aland Islands', 'AZ' => 'Azerbaijan', 'BA' => 'Bosnia and Herzegovina',
0 ignored issues
show
Each index in a multi-line array must be on a new line
Loading history...
This line exceeds maximum limit of 100 characters; contains 126 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
88
        'BB' => 'Barbados', 'BD' => 'Bangladesh', 'BE' => 'Belgium', 'BF' => 'Burkina Faso', 'BG' => 'Bulgaria',
0 ignored issues
show
Each index in a multi-line array must be on a new line
Loading history...
This line exceeds maximum limit of 100 characters; contains 112 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
89
        'BH' => 'Bahrain', 'BI' => 'Burundi', 'BJ' => 'Benin', 'BL' => 'Saint Barthelemy', 'BM' => 'Bermuda',
0 ignored issues
show
Each index in a multi-line array must be on a new line
Loading history...
This line exceeds maximum limit of 100 characters; contains 109 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
90
        'BN' => 'Brunei Darussalam', 'BO' => 'Bolivia', 'BQ' => 'Bonaire, Saint Eustatius and Saba', 'BR' => 'Brazil', 'BS' => 'Bahamas',
0 ignored issues
show
Each index in a multi-line array must be on a new line
Loading history...
This line exceeds maximum limit of 100 characters; contains 137 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
91
        'BT' => 'Bhutan', 'BV' => 'Bouvet Island', 'BW' => 'Botswana', 'BY' => 'Belarus', 'BZ' => 'Belize',
0 ignored issues
show
Each index in a multi-line array must be on a new line
Loading history...
This line exceeds maximum limit of 100 characters; contains 107 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
92
        'CA' => 'Canada', 'CC' => 'Cocos (Keeling) Islands', 'CD' => 'Congo, The Democratic Republic of the', 'CF' => 'Central African Republic', 'CG' => 'Congo',
0 ignored issues
show
Each index in a multi-line array must be on a new line
Loading history...
This line exceeds maximum limit of 100 characters; contains 162 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
93
        'CH' => 'Switzerland', 'CI' => 'Cote D\'Ivoire', 'CK' => 'Cook Islands', 'CL' => 'Chile', 'CM' => 'Cameroon',
0 ignored issues
show
Each index in a multi-line array must be on a new line
Loading history...
This line exceeds maximum limit of 100 characters; contains 117 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
94
        'CN' => 'China', 'CO' => 'Colombia', 'CR' => 'Costa Rica', 'CU' => 'Cuba', 'CV' => 'Cape Verde',
0 ignored issues
show
Each index in a multi-line array must be on a new line
Loading history...
This line exceeds maximum limit of 100 characters; contains 104 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
95
        'CW' => 'Curacao', 'CX' => 'Christmas Island', 'CY' => 'Cyprus', 'CZ' => 'Czech Republic', 'DE' => 'Germany',
0 ignored issues
show
Each index in a multi-line array must be on a new line
Loading history...
This line exceeds maximum limit of 100 characters; contains 117 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
96
        'DJ' => 'Djibouti', 'DK' => 'Denmark', 'DM' => 'Dominica', 'DO' => 'Dominican Republic', 'DZ' => 'Algeria',
0 ignored issues
show
Each index in a multi-line array must be on a new line
Loading history...
This line exceeds maximum limit of 100 characters; contains 115 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
97
        'EC' => 'Ecuador', 'EE' => 'Estonia', 'EG' => 'Egypt', 'EH' => 'Western Sahara', 'ER' => 'Eritrea',
0 ignored issues
show
Each index in a multi-line array must be on a new line
Loading history...
This line exceeds maximum limit of 100 characters; contains 107 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
98
        'ES' => 'Spain', 'ET' => 'Ethiopia', 'EU' => 'Europe', 'FI' => 'Finland', 'FJ' => 'Fiji',
0 ignored issues
show
Each index in a multi-line array must be on a new line
Loading history...
99
        'FK' => 'Falkland Islands (Malvinas)', 'FM' => 'Micronesia, Federated States of', 'FO' => 'Faroe Islands', 'FR' => 'France', 'GA' => 'Gabon',
0 ignored issues
show
Each index in a multi-line array must be on a new line
Loading history...
This line exceeds maximum limit of 100 characters; contains 149 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
100
        'GB' => 'United Kingdom', 'GD' => 'Grenada', 'GE' => 'Georgia', 'GF' => 'French Guiana', 'GG' => 'Guernsey',
0 ignored issues
show
Each index in a multi-line array must be on a new line
Loading history...
This line exceeds maximum limit of 100 characters; contains 116 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
101
        'GH' => 'Ghana', 'GI' => 'Gibraltar', 'GL' => 'Greenland', 'GM' => 'Gambia', 'GN' => 'Guinea',
0 ignored issues
show
Each index in a multi-line array must be on a new line
Loading history...
This line exceeds maximum limit of 100 characters; contains 102 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
102
        'GP' => 'Guadeloupe', 'GQ' => 'Equatorial Guinea', 'GR' => 'Greece', 'GS' => 'South Georgia and the South Sandwich Islands', 'GT' => 'Guatemala',
0 ignored issues
show
Each index in a multi-line array must be on a new line
Loading history...
This line exceeds maximum limit of 100 characters; contains 153 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
103
        'GU' => 'Guam', 'GW' => 'Guinea-Bissau', 'GY' => 'Guyana', 'HK' => 'Hong Kong', 'HM' => 'Heard Island and McDonald Islands',
0 ignored issues
show
Each index in a multi-line array must be on a new line
Loading history...
This line exceeds maximum limit of 100 characters; contains 132 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
104
        'HN' => 'Honduras', 'HR' => 'Croatia', 'HT' => 'Haiti', 'HU' => 'Hungary', 'ID' => 'Indonesia',
0 ignored issues
show
Each index in a multi-line array must be on a new line
Loading history...
This line exceeds maximum limit of 100 characters; contains 103 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
105
        'IE' => 'Ireland', 'IL' => 'Israel', 'IM' => 'Isle of Man', 'IN' => 'India', 'IO' => 'British Indian Ocean Territory',
0 ignored issues
show
Each index in a multi-line array must be on a new line
Loading history...
This line exceeds maximum limit of 100 characters; contains 126 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
106
        'IQ' => 'Iraq', 'IR' => 'Iran, Islamic Republic of', 'IS' => 'Iceland', 'IT' => 'Italy', 'JE' => 'Jersey',
0 ignored issues
show
Each index in a multi-line array must be on a new line
Loading history...
This line exceeds maximum limit of 100 characters; contains 114 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
107
        'JM' => 'Jamaica', 'JO' => 'Jordan', 'JP' => 'Japan', 'KE' => 'Kenya', 'KG' => 'Kyrgyzstan',
0 ignored issues
show
Each index in a multi-line array must be on a new line
Loading history...
108
        'KH' => 'Cambodia', 'KI' => 'Kiribati', 'KM' => 'Comoros', 'KN' => 'Saint Kitts and Nevis', 'KP' => 'Korea, Democratic People\'s Republic of',
0 ignored issues
show
Each index in a multi-line array must be on a new line
Loading history...
This line exceeds maximum limit of 100 characters; contains 150 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
109
        'KR' => 'Korea, Republic of', 'KW' => 'Kuwait', 'KY' => 'Cayman Islands', 'KZ' => 'Kazakhstan', 'LA' => 'Lao People\'s Democratic Republic',
0 ignored issues
show
Each index in a multi-line array must be on a new line
Loading history...
This line exceeds maximum limit of 100 characters; contains 148 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
110
        'LB' => 'Lebanon', 'LC' => 'Saint Lucia', 'LI' => 'Liechtenstein', 'LK' => 'Sri Lanka', 'LR' => 'Liberia',
0 ignored issues
show
Each index in a multi-line array must be on a new line
Loading history...
This line exceeds maximum limit of 100 characters; contains 114 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
111
        'LS' => 'Lesotho', 'LT' => 'Lithuania', 'LU' => 'Luxembourg', 'LV' => 'Latvia', 'LY' => 'Libya',
0 ignored issues
show
Each index in a multi-line array must be on a new line
Loading history...
This line exceeds maximum limit of 100 characters; contains 104 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
112
        'MA' => 'Morocco', 'MC' => 'Monaco', 'MD' => 'Moldova, Republic of', 'ME' => 'Montenegro', 'MF' => 'Saint Martin',
0 ignored issues
show
Each index in a multi-line array must be on a new line
Loading history...
This line exceeds maximum limit of 100 characters; contains 122 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
113
        'MG' => 'Madagascar', 'MH' => 'Marshall Islands', 'MK' => 'Macedonia', 'ML' => 'Mali', 'MM' => 'Myanmar',
0 ignored issues
show
Each index in a multi-line array must be on a new line
Loading history...
This line exceeds maximum limit of 100 characters; contains 113 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
114
        'MN' => 'Mongolia', 'MO' => 'Macau', 'MP' => 'Northern Mariana Islands', 'MQ' => 'Martinique', 'MR' => 'Mauritania',
0 ignored issues
show
Each index in a multi-line array must be on a new line
Loading history...
This line exceeds maximum limit of 100 characters; contains 124 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
115
        'MS' => 'Montserrat', 'MT' => 'Malta', 'MU' => 'Mauritius', 'MV' => 'Maldives', 'MW' => 'Malawi',
0 ignored issues
show
Each index in a multi-line array must be on a new line
Loading history...
This line exceeds maximum limit of 100 characters; contains 105 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
116
        'MX' => 'Mexico', 'MY' => 'Malaysia', 'MZ' => 'Mozambique', 'NA' => 'Namibia', 'NC' => 'New Caledonia',
0 ignored issues
show
Each index in a multi-line array must be on a new line
Loading history...
This line exceeds maximum limit of 100 characters; contains 111 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
117
        'NE' => 'Niger', 'NF' => 'Norfolk Island', 'NG' => 'Nigeria', 'NI' => 'Nicaragua', 'NL' => 'Netherlands',
0 ignored issues
show
Each index in a multi-line array must be on a new line
Loading history...
This line exceeds maximum limit of 100 characters; contains 113 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
118
        'NO' => 'Norway', 'NP' => 'Nepal', 'NR' => 'Nauru', 'NU' => 'Niue', 'NZ' => 'New Zealand',
0 ignored issues
show
Each index in a multi-line array must be on a new line
Loading history...
119
        'O1' => 'Other', 'OM' => 'Oman', 'PA' => 'Panama', 'PE' => 'Peru', 'PF' => 'French Polynesia',
0 ignored issues
show
Each index in a multi-line array must be on a new line
Loading history...
This line exceeds maximum limit of 100 characters; contains 102 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
120
        'PG' => 'Papua New Guinea', 'PH' => 'Philippines', 'PK' => 'Pakistan', 'PL' => 'Poland', 'PM' => 'Saint Pierre and Miquelon',
0 ignored issues
show
Each index in a multi-line array must be on a new line
Loading history...
This line exceeds maximum limit of 100 characters; contains 133 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
121
        'PN' => 'Pitcairn Islands', 'PR' => 'Puerto Rico', 'PS' => 'Palestinian Territory', 'PT' => 'Portugal', 'PW' => 'Palau',
0 ignored issues
show
Each index in a multi-line array must be on a new line
Loading history...
This line exceeds maximum limit of 100 characters; contains 128 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
122
        'PY' => 'Paraguay', 'QA' => 'Qatar', 'RE' => 'Reunion', 'RO' => 'Romania', 'RS' => 'Serbia',
0 ignored issues
show
Each index in a multi-line array must be on a new line
Loading history...
123
        'RU' => 'Russian Federation', 'RW' => 'Rwanda', 'SA' => 'Saudi Arabia', 'SB' => 'Solomon Islands', 'SC' => 'Seychelles',
0 ignored issues
show
Each index in a multi-line array must be on a new line
Loading history...
This line exceeds maximum limit of 100 characters; contains 128 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
124
        'SD' => 'Sudan', 'SE' => 'Sweden', 'SG' => 'Singapore', 'SH' => 'Saint Helena', 'SI' => 'Slovenia',
0 ignored issues
show
Each index in a multi-line array must be on a new line
Loading history...
This line exceeds maximum limit of 100 characters; contains 107 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
125
        'SJ' => 'Svalbard and Jan Mayen', 'SK' => 'Slovakia', 'SL' => 'Sierra Leone', 'SM' => 'San Marino', 'SN' => 'Senegal',
0 ignored issues
show
Each index in a multi-line array must be on a new line
Loading history...
This line exceeds maximum limit of 100 characters; contains 126 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
126
        'SO' => 'Somalia', 'SR' => 'Suriname', 'SS' => 'South Sudan', 'ST' => 'Sao Tome and Principe', 'SV' => 'El Salvador',
0 ignored issues
show
Each index in a multi-line array must be on a new line
Loading history...
This line exceeds maximum limit of 100 characters; contains 125 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
127
        'SX' => 'Sint Maarten (Dutch part)', 'SY' => 'Syrian Arab Republic', 'SZ' => 'Swaziland', 'TC' => 'Turks and Caicos Islands', 'TD' => 'Chad',
0 ignored issues
show
Each index in a multi-line array must be on a new line
Loading history...
This line exceeds maximum limit of 100 characters; contains 149 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
128
        'TF' => 'French Southern Territories', 'TG' => 'Togo', 'TH' => 'Thailand', 'TJ' => 'Tajikistan', 'TK' => 'Tokelau',
0 ignored issues
show
Each index in a multi-line array must be on a new line
Loading history...
This line exceeds maximum limit of 100 characters; contains 123 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
129
        'TL' => 'Timor-Leste', 'TM' => 'Turkmenistan', 'TN' => 'Tunisia', 'TO' => 'Tonga', 'TR' => 'Turkey',
0 ignored issues
show
Each index in a multi-line array must be on a new line
Loading history...
This line exceeds maximum limit of 100 characters; contains 108 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
130
        'TT' => 'Trinidad and Tobago', 'TV' => 'Tuvalu', 'TW' => 'Taiwan', 'TZ' => 'Tanzania, United Republic of', 'UA' => 'Ukraine',
0 ignored issues
show
Each index in a multi-line array must be on a new line
Loading history...
This line exceeds maximum limit of 100 characters; contains 133 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
131
        'UG' => 'Uganda', 'UM' => 'United States Minor Outlying Islands', 'US' => 'United States', 'UY' => 'Uruguay', 'UZ' => 'Uzbekistan',
0 ignored issues
show
Each index in a multi-line array must be on a new line
Loading history...
This line exceeds maximum limit of 100 characters; contains 139 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
132
        'VA' => 'Holy See (Vatican City State)', 'VC' => 'Saint Vincent and the Grenadines', 'VE' => 'Venezuela', 'VG' => 'Virgin Islands, British', 'VI' => 'Virgin Islands, U.S.',
0 ignored issues
show
Each index in a multi-line array must be on a new line
Loading history...
This line exceeds maximum limit of 100 characters; contains 180 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
133
        'VN' => 'Vietnam', 'VU' => 'Vanuatu', 'WF' => 'Wallis and Futuna', 'WS' => 'Samoa', 'YE' => 'Yemen',
0 ignored issues
show
Each index in a multi-line array must be on a new line
Loading history...
This line exceeds maximum limit of 100 characters; contains 108 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
134
        'YT' => 'Mayotte', 'ZA' => 'South Africa', 'ZM' => 'Zambia', 'ZW' => 'Zimbabwe',
0 ignored issues
show
Each index in a multi-line array must be on a new line
Loading history...
135
    ];
0 ignored issues
show
The closing parenthesis does not seem to be aligned correctly; expected 17 space(s), but found 4.
Loading history...
136
137 4
    $code = strtoupper( $code );
138
139 4
    return yourls_apply_filter( 'geo_countrycode_to_countryname', isset( $countries[ $code ] ) ? $countries[ $code ] : '' );
0 ignored issues
show
This line exceeds maximum limit of 100 characters; contains 124 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
140
}
141
142
/**
143
 * Return flag URL from 2 letter country code
144
 * @param string $code
145
 * @return string
146
 */
147
function yourls_geo_get_flag( $code ) {
148 1
    if ( !file_exists( YOURLS_INC.'/geo/flags/flag_'.strtolower( $code ).'.gif' ) ) {
149 1
        $code = '';
150
    }
151 1
    $img = yourls_match_current_protocol( yourls_get_yourls_site().'/includes/geo/flags/flag_'.strtolower( $code ).'.gif' );
0 ignored issues
show
This line exceeds maximum limit of 100 characters; contains 124 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
152 1
    return (string)yourls_apply_filter( 'geo_get_flag', $img, $code );
153
}
154