Code Duplication    Length = 18-19 lines in 4 locations

catalog/includes/apps/braintree/OSCOM_Braintree.php 1 location

@@ 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

catalog/includes/apps/paypal/OSCOM_PayPal.php 1 location

@@ 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

catalog/admin/includes/functions/general.php 1 location

@@ 1395-1413 (lines=19) @@
1392
    return $tmp_array;
1393
  }
1394
1395
  function tep_validate_ip_address($ip_address) {
1396
    if (function_exists('filter_var') && defined('FILTER_VALIDATE_IP')) {
1397
      return filter_var($ip_address, FILTER_VALIDATE_IP, array('flags' => FILTER_FLAG_IPV4));
1398
    }
1399
1400
    if (preg_match('/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/', $ip_address)) {
1401
      $parts = explode('.', $ip_address);
1402
1403
      foreach ($parts as $ip_parts) {
1404
        if ( (intval($ip_parts) > 255) || (intval($ip_parts) < 0) ) {
1405
          return false; // number is not within 0-255
1406
        }
1407
      }
1408
1409
      return true;
1410
    }
1411
1412
    return false;
1413
  }
1414
1415
  function tep_get_ip_address() {
1416
    global $HTTP_SERVER_VARS;

catalog/includes/functions/general.php 1 location

@@ 1278-1296 (lines=19) @@
1275
    setcookie($name, $value, $expire, $path, (tep_not_null($domain) ? $domain : ''), $secure);
1276
  }
1277
1278
  function tep_validate_ip_address($ip_address) {
1279
    if (function_exists('filter_var') && defined('FILTER_VALIDATE_IP')) {
1280
      return filter_var($ip_address, FILTER_VALIDATE_IP, array('flags' => FILTER_FLAG_IPV4));
1281
    }
1282
1283
    if (preg_match('/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/', $ip_address)) {
1284
      $parts = explode('.', $ip_address);
1285
1286
      foreach ($parts as $ip_parts) {
1287
        if ( (intval($ip_parts) > 255) || (intval($ip_parts) < 0) ) {
1288
          return false; // number is not within 0-255
1289
        }
1290
      }
1291
1292
      return true;
1293
    }
1294
1295
    return false;
1296
  }
1297
1298
  function tep_get_ip_address() {
1299
    global $HTTP_SERVER_VARS;