@@ 1383-1401 (lines=19) @@ | ||
1380 | return $tmp_array; |
|
1381 | } |
|
1382 | ||
1383 | function tep_validate_ip_address($ip_address) { |
|
1384 | if (function_exists('filter_var') && defined('FILTER_VALIDATE_IP')) { |
|
1385 | return filter_var($ip_address, FILTER_VALIDATE_IP, array('flags' => FILTER_FLAG_IPV4)); |
|
1386 | } |
|
1387 | ||
1388 | if (preg_match('/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/', $ip_address)) { |
|
1389 | $parts = explode('.', $ip_address); |
|
1390 | ||
1391 | foreach ($parts as $ip_parts) { |
|
1392 | if ( (intval($ip_parts) > 255) || (intval($ip_parts) < 0) ) { |
|
1393 | return false; // number is not within 0-255 |
|
1394 | } |
|
1395 | } |
|
1396 | ||
1397 | return true; |
|
1398 | } |
|
1399 | ||
1400 | return false; |
|
1401 | } |
|
1402 | ||
1403 | function tep_get_ip_address() { |
|
1404 | global $HTTP_SERVER_VARS; |
@@ 1280-1298 (lines=19) @@ | ||
1277 | setcookie($name, $value, $expire, $path, (tep_not_null($domain) ? $domain : ''), $secure); |
|
1278 | } |
|
1279 | ||
1280 | function tep_validate_ip_address($ip_address) { |
|
1281 | if (function_exists('filter_var') && defined('FILTER_VALIDATE_IP')) { |
|
1282 | return filter_var($ip_address, FILTER_VALIDATE_IP, array('flags' => FILTER_FLAG_IPV4)); |
|
1283 | } |
|
1284 | ||
1285 | if (preg_match('/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/', $ip_address)) { |
|
1286 | $parts = explode('.', $ip_address); |
|
1287 | ||
1288 | foreach ($parts as $ip_parts) { |
|
1289 | if ( (intval($ip_parts) > 255) || (intval($ip_parts) < 0) ) { |
|
1290 | return false; // number is not within 0-255 |
|
1291 | } |
|
1292 | } |
|
1293 | ||
1294 | return true; |
|
1295 | } |
|
1296 | ||
1297 | return false; |
|
1298 | } |
|
1299 | ||
1300 | function tep_get_ip_address() { |
|
1301 | global $HTTP_SERVER_VARS; |
@@ 858-875 (lines=18) @@ | ||
855 | return $ip_address; |
|
856 | } |
|
857 | // OSCOM v2.2rc2a compatibility |
|
858 | function isValidIpAddress($ip_address) { |
|
859 | if ( function_exists('tep_validate_ip_address') ) { |
|
860 | return tep_validate_ip_address($ip_address); |
|
861 | } |
|
862 | if (function_exists('filter_var') && defined('FILTER_VALIDATE_IP')) { |
|
863 | return filter_var($ip_address, FILTER_VALIDATE_IP, array('flags' => FILTER_FLAG_IPV4)); |
|
864 | } |
|
865 | if (preg_match('/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/', $ip_address)) { |
|
866 | $parts = explode('.', $ip_address); |
|
867 | foreach ($parts as $ip_parts) { |
|
868 | if ( (intval($ip_parts) > 255) || (intval($ip_parts) < 0) ) { |
|
869 | return false; // number is not within 0-255 |
|
870 | } |
|
871 | } |
|
872 | return true; |
|
873 | } |
|
874 | return false; |
|
875 | } |
|
876 | } |
|
877 | ?> |
|
878 |
@@ 910-927 (lines=18) @@ | ||
907 | return $ip_address; |
|
908 | } |
|
909 | // OSCOM v2.2rc2a compatibility |
|
910 | function isValidIpAddress($ip_address) { |
|
911 | if ( function_exists('tep_validate_ip_address') ) { |
|
912 | return tep_validate_ip_address($ip_address); |
|
913 | } |
|
914 | if (function_exists('filter_var') && defined('FILTER_VALIDATE_IP')) { |
|
915 | return filter_var($ip_address, FILTER_VALIDATE_IP, array('flags' => FILTER_FLAG_IPV4)); |
|
916 | } |
|
917 | if (preg_match('/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/', $ip_address)) { |
|
918 | $parts = explode('.', $ip_address); |
|
919 | foreach ($parts as $ip_parts) { |
|
920 | if ( (intval($ip_parts) > 255) || (intval($ip_parts) < 0) ) { |
|
921 | return false; // number is not within 0-255 |
|
922 | } |
|
923 | } |
|
924 | return true; |
|
925 | } |
|
926 | return false; |
|
927 | } |
|
928 | } |
|
929 | ?> |
|
930 |