Remove trailing whitespace

This commit is contained in:
Kijin Sung 2023-01-17 20:57:44 +09:00
parent 3b0030e82b
commit a9f72a5cd2
81 changed files with 2455 additions and 2455 deletions

View file

@ -9,7 +9,7 @@ class Korea
{
/**
* Format a phone number.
*
*
* @param string $num
* @return string
*/
@ -17,7 +17,7 @@ class Korea
{
// Remove all non-numbers.
$num = preg_replace('/[^0-9]/', '', $num);
// Remove the country code.
if (strncmp($num, '82', 2) === 0)
{
@ -27,7 +27,7 @@ class Korea
$num = '0' . $num;
}
}
// Apply different format based on the number of digits.
switch (strlen($num))
{
@ -62,10 +62,10 @@ class Korea
}
}
}
/**
* Check if a Korean phone number contains a valid area code and the correct number of digits.
*
*
* @param string $num
* @return bool
*/
@ -90,10 +90,10 @@ class Korea
}
return false;
}
/**
* Check if a Korean phone number is a mobile phone number.
*
*
* @param string $num
* @return bool
*/
@ -103,14 +103,14 @@ class Korea
$len = strlen($num);
return preg_match('/^01[016789][2-9][0-9]{6,7}$/', $num) ? true : false;
}
/**
* Check if the given string is a valid resident registration number (주민등록번호)
* or foreigner registration number (외국인등록번호).
*
*
* This method only checks the format.
* It does not check that the number is actually in use.
*
*
* @param string $code
* @return bool
*/
@ -121,16 +121,16 @@ class Korea
{
return false;
}
// Remove hyphen.
$code = str_replace('-', '', $code);
// Return false if the date of birth is in the future.
if (in_array((int)($code[6]), array(3, 4, 7, 8)) && intval(substr($code, 0, 6), 10) > date('ymd'))
{
return false;
}
// Calculate the checksum.
$sum = 0;
for ($i = 0; $i < 12; $i++)
@ -154,13 +154,13 @@ class Korea
}
}
}
/**
* Check if the given string is a valid corporation registration number (법인등록번호).
*
*
* This method only checks the format.
* It does not check that the number is actually in use.
*
*
* @param string $code
* @return bool
*/
@ -171,10 +171,10 @@ class Korea
{
return false;
}
// Remove hyphen.
$code = str_replace('-', '', $code);
// Calculate the checksum.
$sum = 0;
for ($i = 0; $i < 12; $i++)
@ -182,7 +182,7 @@ class Korea
$sum += $code[$i] * (($i % 2) + 1);
}
$checksum = (10 - ($sum % 10)) % 10;
// Check the 7th and 13th digits.
if ($code[6] !== '0')
{
@ -190,13 +190,13 @@ class Korea
}
return $checksum === (int)($code[12]);
}
/**
* Check if the given string is a valid business registration number (사업자등록번호).
*
*
* This method only checks the format.
* It does not check that the number is actually in use.
*
*
* @param string $code
* @return bool
*/
@ -207,10 +207,10 @@ class Korea
{
return false;
}
// Remove hyphen.
$code = str_replace('-', '', $code);
// Calculate the checksum.
$sum = 0;
$sum += $code[0] + ($code[1] * 3) + ($code[2] * 7);
@ -218,17 +218,17 @@ class Korea
$sum += $code[6] + ($code[7] * 3) + ($code[8] * 5);
$sum += floor(($code[8] * 5) / 10);
$checksum = (10 - ($sum % 10)) % 10;
// Check the last digit.
return $checksum === (int)($code[9]);
}
/**
* Check if the given IP address is Korean.
*
* This method may return incorrect results if the IP allocation databases
* (korea.ipv4.php, korea.ipv6.php) are out of date.
*
*
* @param string $ip
* @return bool
*/
@ -236,22 +236,22 @@ class Korea
{
// Extract the IPv4 address from an "IPv4-mapped IPv6" address.
if (preg_match('/::ffff:(?:0+:)?([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)$/', $ip, $matches)) $ip = $matches[1];
// Return false if the IP address is not in the right format.
if (!filter_var($ip, \FILTER_VALIDATE_IP)) return false;
// Check IPv4.
if (filter_var($ip, \FILTER_VALIDATE_IP, array('flags' => \FILTER_FLAG_IPV4)))
{
// Convert to integer.
$ipnum = sprintf('%u', ip2long($ip));
// Treat local addresses as Korean.
if ($ipnum >= 167772160 && $ipnum <= 184549375) return true; // 10.0.0.0/8
if ($ipnum >= 2130706432 && $ipnum <= 2147483647) return true; // 127.0.0.0/8
if ($ipnum >= 3232235520 && $ipnum <= 3232301055) return true; // 192.168.0.0/16
if ($ipnum >= 2886729728 && $ipnum <= 2887778303) return true; // 172.16.0.0/20
// Check the IPv4 allocation database.
$ranges = (include \RX_BASEDIR . 'common/defaults/korea.ipv4.php');
foreach ($ranges as $range)
@ -260,17 +260,17 @@ class Korea
}
return false;
}
// Check IPv6.
elseif (function_exists('inet_pton'))
{
// Convert to hexadecimal format.
$ipbin = strtolower(bin2hex(inet_pton($ip)));
// Treat local addresses as Korean.
if ($ipbin == '00000000000000000000000000000001') return true; // ::1
if (preg_match('/^f(?:[cd]|e80{13})/', $ipbin)) return true; // fc00::/8, fd00::/8, fe80::/64
// Check the IPv6 allocation database.
$ranges = (include \RX_BASEDIR . 'common/defaults/korea.ipv6.php');
foreach ($ranges as $range)
@ -279,16 +279,16 @@ class Korea
}
return false;
}
return false;
}
/**
* Check if the given email address is hosted by a Korean portal site.
*
*
* This can be used to tell which recipients may subscribe to the KISA RBL (kisarbl.or.kr).
* If the domain is not found, this method returns false.
*
*
* @param string $domain
* @param bool $clear_cache (optional)
* @return bool
@ -300,7 +300,7 @@ class Korea
{
self::$_domain_cache = array();
}
// Get the domain from the email address.
if ($pos = strpos($email_address, '@'))
{
@ -311,13 +311,13 @@ class Korea
$domain = $email_address;
}
$domain = rtrim(strtolower($domain), '.');
// Return cached result if available.
if (array_key_exists($domain, self::$_domain_cache))
{
return self::$_domain_cache[$domain];
}
// Shortcut for known domains.
if (in_array($domain, self::$known_korean))
{
@ -327,10 +327,10 @@ class Korea
{
return self::$_domain_cache[$domain] = false;
}
// For unknown domains, check the MX record.
$mx = self::_getDNSRecords($domain, \DNS_MX);
$i = 0;
foreach ($mx as $mx)
{
@ -358,13 +358,13 @@ class Korea
break;
}
}
return self::$_domain_cache[$domain] = false;
}
/**
* Get the DNS records of a domain.
*
*
* @param string $domain
* @param int $type
* @return array
@ -376,7 +376,7 @@ class Korea
{
return array();
}
$result = array();
foreach ($records as $record)
{
@ -397,16 +397,16 @@ class Korea
$result[] = $record['txt'];
}
}
ksort($result);
return $result;
}
/**
* Prevent multiple lookups for the same domain.
*/
protected static $_domain_cache = array();
/**
* Domains known to be Korean and subscribed to the KISA RBL.
*/
@ -432,7 +432,7 @@ class Korea
'empal.com',
'hanafos.com',
);
/**
* Domains known to be foreign.
*/