Code Duplication    Length = 33-33 lines in 2 locations

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

@@ 796-828 (lines=33) @@
793
      return str_replace('/', DIRECTORY_SEPARATOR, $pathname);
794
    }
795
// OSCOM v2.2rc2a compatibility
796
    function getIpAddress() {
797
      if ( function_exists('tep_get_ip_address') ) {
798
        return tep_get_ip_address();
799
      }
800
      global $HTTP_SERVER_VARS;
801
      $ip_address = null;
802
      $ip_addresses = array();
803
      if (isset($HTTP_SERVER_VARS['HTTP_X_FORWARDED_FOR']) && !empty($HTTP_SERVER_VARS['HTTP_X_FORWARDED_FOR'])) {
804
        foreach ( array_reverse(explode(',', $HTTP_SERVER_VARS['HTTP_X_FORWARDED_FOR'])) as $x_ip ) {
805
          $x_ip = trim($x_ip);
806
          if ($this->isValidIpAddress($x_ip)) {
807
            $ip_addresses[] = $x_ip;
808
          }
809
        }
810
      }
811
      if (isset($HTTP_SERVER_VARS['HTTP_CLIENT_IP']) && !empty($HTTP_SERVER_VARS['HTTP_CLIENT_IP'])) {
812
        $ip_addresses[] = $HTTP_SERVER_VARS['HTTP_CLIENT_IP'];
813
      }
814
      if (isset($HTTP_SERVER_VARS['HTTP_X_CLUSTER_CLIENT_IP']) && !empty($HTTP_SERVER_VARS['HTTP_X_CLUSTER_CLIENT_IP'])) {
815
        $ip_addresses[] = $HTTP_SERVER_VARS['HTTP_X_CLUSTER_CLIENT_IP'];
816
      }
817
      if (isset($HTTP_SERVER_VARS['HTTP_PROXY_USER']) && !empty($HTTP_SERVER_VARS['HTTP_PROXY_USER'])) {
818
        $ip_addresses[] = $HTTP_SERVER_VARS['HTTP_PROXY_USER'];
819
      }
820
      $ip_addresses[] = $HTTP_SERVER_VARS['REMOTE_ADDR'];
821
      foreach ( $ip_addresses as $ip ) {
822
        if (!empty($ip) && $this->isValidIpAddress($ip)) {
823
          $ip_address = $ip;
824
          break;
825
        }
826
      }
827
      return $ip_address;
828
    }
829
// OSCOM v2.2rc2a compatibility
830
    function isValidIpAddress($ip_address) {
831
      if ( function_exists('tep_validate_ip_address') ) {

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

@@ 850-882 (lines=33) @@
847
      return str_replace('/', DIRECTORY_SEPARATOR, $pathname);
848
    }
849
// OSCOM v2.2rc2a compatibility
850
    function getIpAddress() {
851
      if ( function_exists('tep_get_ip_address') ) {
852
        return tep_get_ip_address();
853
      }
854
      global $HTTP_SERVER_VARS;
855
      $ip_address = null;
856
      $ip_addresses = array();
857
      if (isset($HTTP_SERVER_VARS['HTTP_X_FORWARDED_FOR']) && !empty($HTTP_SERVER_VARS['HTTP_X_FORWARDED_FOR'])) {
858
        foreach ( array_reverse(explode(',', $HTTP_SERVER_VARS['HTTP_X_FORWARDED_FOR'])) as $x_ip ) {
859
          $x_ip = trim($x_ip);
860
          if ($this->isValidIpAddress($x_ip)) {
861
            $ip_addresses[] = $x_ip;
862
          }
863
        }
864
      }
865
      if (isset($HTTP_SERVER_VARS['HTTP_CLIENT_IP']) && !empty($HTTP_SERVER_VARS['HTTP_CLIENT_IP'])) {
866
        $ip_addresses[] = $HTTP_SERVER_VARS['HTTP_CLIENT_IP'];
867
      }
868
      if (isset($HTTP_SERVER_VARS['HTTP_X_CLUSTER_CLIENT_IP']) && !empty($HTTP_SERVER_VARS['HTTP_X_CLUSTER_CLIENT_IP'])) {
869
        $ip_addresses[] = $HTTP_SERVER_VARS['HTTP_X_CLUSTER_CLIENT_IP'];
870
      }
871
      if (isset($HTTP_SERVER_VARS['HTTP_PROXY_USER']) && !empty($HTTP_SERVER_VARS['HTTP_PROXY_USER'])) {
872
        $ip_addresses[] = $HTTP_SERVER_VARS['HTTP_PROXY_USER'];
873
      }
874
      $ip_addresses[] = $HTTP_SERVER_VARS['REMOTE_ADDR'];
875
      foreach ( $ip_addresses as $ip ) {
876
        if (!empty($ip) && $this->isValidIpAddress($ip)) {
877
          $ip_address = $ip;
878
          break;
879
        }
880
      }
881
      return $ip_address;
882
    }
883
// OSCOM v2.2rc2a compatibility
884
    function isValidIpAddress($ip_address) {
885
      if ( function_exists('tep_validate_ip_address') ) {