@@ 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; |
@@ 830-847 (lines=18) @@ | ||
827 | return $ip_address; |
|
828 | } |
|
829 | // OSCOM v2.2rc2a compatibility |
|
830 | function isValidIpAddress($ip_address) { |
|
831 | if ( function_exists('tep_validate_ip_address') ) { |
|
832 | return tep_validate_ip_address($ip_address); |
|
833 | } |
|
834 | if (function_exists('filter_var') && defined('FILTER_VALIDATE_IP')) { |
|
835 | return filter_var($ip_address, FILTER_VALIDATE_IP, array('flags' => FILTER_FLAG_IPV4)); |
|
836 | } |
|
837 | if (preg_match('/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/', $ip_address)) { |
|
838 | $parts = explode('.', $ip_address); |
|
839 | foreach ($parts as $ip_parts) { |
|
840 | if ( (intval($ip_parts) > 255) || (intval($ip_parts) < 0) ) { |
|
841 | return false; // number is not within 0-255 |
|
842 | } |
|
843 | } |
|
844 | return true; |
|
845 | } |
|
846 | return false; |
|
847 | } |
|
848 | } |
|
849 | ?> |
|
850 |
@@ 884-901 (lines=18) @@ | ||
881 | return $ip_address; |
|
882 | } |
|
883 | // OSCOM v2.2rc2a compatibility |
|
884 | function isValidIpAddress($ip_address) { |
|
885 | if ( function_exists('tep_validate_ip_address') ) { |
|
886 | return tep_validate_ip_address($ip_address); |
|
887 | } |
|
888 | if (function_exists('filter_var') && defined('FILTER_VALIDATE_IP')) { |
|
889 | return filter_var($ip_address, FILTER_VALIDATE_IP, array('flags' => FILTER_FLAG_IPV4)); |
|
890 | } |
|
891 | if (preg_match('/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/', $ip_address)) { |
|
892 | $parts = explode('.', $ip_address); |
|
893 | foreach ($parts as $ip_parts) { |
|
894 | if ( (intval($ip_parts) > 255) || (intval($ip_parts) < 0) ) { |
|
895 | return false; // number is not within 0-255 |
|
896 | } |
|
897 | } |
|
898 | return true; |
|
899 | } |
|
900 | return false; |
|
901 | } |
|
902 | } |
|
903 | ?> |
|
904 |