Code Duplication    Length = 33-33 lines in 2 locations

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

@@ 824-856 (lines=33) @@
821
      return str_replace('/', DIRECTORY_SEPARATOR, $pathname);
822
    }
823
// OSCOM v2.2rc2a compatibility
824
    function getIpAddress() {
825
      if ( function_exists('tep_get_ip_address') ) {
826
        return tep_get_ip_address();
827
      }
828
      global $HTTP_SERVER_VARS;
829
      $ip_address = null;
830
      $ip_addresses = array();
831
      if (isset($HTTP_SERVER_VARS['HTTP_X_FORWARDED_FOR']) && !empty($HTTP_SERVER_VARS['HTTP_X_FORWARDED_FOR'])) {
832
        foreach ( array_reverse(explode(',', $HTTP_SERVER_VARS['HTTP_X_FORWARDED_FOR'])) as $x_ip ) {
833
          $x_ip = trim($x_ip);
834
          if ($this->isValidIpAddress($x_ip)) {
835
            $ip_addresses[] = $x_ip;
836
          }
837
        }
838
      }
839
      if (isset($HTTP_SERVER_VARS['HTTP_CLIENT_IP']) && !empty($HTTP_SERVER_VARS['HTTP_CLIENT_IP'])) {
840
        $ip_addresses[] = $HTTP_SERVER_VARS['HTTP_CLIENT_IP'];
841
      }
842
      if (isset($HTTP_SERVER_VARS['HTTP_X_CLUSTER_CLIENT_IP']) && !empty($HTTP_SERVER_VARS['HTTP_X_CLUSTER_CLIENT_IP'])) {
843
        $ip_addresses[] = $HTTP_SERVER_VARS['HTTP_X_CLUSTER_CLIENT_IP'];
844
      }
845
      if (isset($HTTP_SERVER_VARS['HTTP_PROXY_USER']) && !empty($HTTP_SERVER_VARS['HTTP_PROXY_USER'])) {
846
        $ip_addresses[] = $HTTP_SERVER_VARS['HTTP_PROXY_USER'];
847
      }
848
      $ip_addresses[] = $HTTP_SERVER_VARS['REMOTE_ADDR'];
849
      foreach ( $ip_addresses as $ip ) {
850
        if (!empty($ip) && $this->isValidIpAddress($ip)) {
851
          $ip_address = $ip;
852
          break;
853
        }
854
      }
855
      return $ip_address;
856
    }
857
// OSCOM v2.2rc2a compatibility
858
    function isValidIpAddress($ip_address) {
859
      if ( function_exists('tep_validate_ip_address') ) {

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

@@ 876-908 (lines=33) @@
873
      return str_replace('/', DIRECTORY_SEPARATOR, $pathname);
874
    }
875
// OSCOM v2.2rc2a compatibility
876
    function getIpAddress() {
877
      if ( function_exists('tep_get_ip_address') ) {
878
        return tep_get_ip_address();
879
      }
880
      global $HTTP_SERVER_VARS;
881
      $ip_address = null;
882
      $ip_addresses = array();
883
      if (isset($HTTP_SERVER_VARS['HTTP_X_FORWARDED_FOR']) && !empty($HTTP_SERVER_VARS['HTTP_X_FORWARDED_FOR'])) {
884
        foreach ( array_reverse(explode(',', $HTTP_SERVER_VARS['HTTP_X_FORWARDED_FOR'])) as $x_ip ) {
885
          $x_ip = trim($x_ip);
886
          if ($this->isValidIpAddress($x_ip)) {
887
            $ip_addresses[] = $x_ip;
888
          }
889
        }
890
      }
891
      if (isset($HTTP_SERVER_VARS['HTTP_CLIENT_IP']) && !empty($HTTP_SERVER_VARS['HTTP_CLIENT_IP'])) {
892
        $ip_addresses[] = $HTTP_SERVER_VARS['HTTP_CLIENT_IP'];
893
      }
894
      if (isset($HTTP_SERVER_VARS['HTTP_X_CLUSTER_CLIENT_IP']) && !empty($HTTP_SERVER_VARS['HTTP_X_CLUSTER_CLIENT_IP'])) {
895
        $ip_addresses[] = $HTTP_SERVER_VARS['HTTP_X_CLUSTER_CLIENT_IP'];
896
      }
897
      if (isset($HTTP_SERVER_VARS['HTTP_PROXY_USER']) && !empty($HTTP_SERVER_VARS['HTTP_PROXY_USER'])) {
898
        $ip_addresses[] = $HTTP_SERVER_VARS['HTTP_PROXY_USER'];
899
      }
900
      $ip_addresses[] = $HTTP_SERVER_VARS['REMOTE_ADDR'];
901
      foreach ( $ip_addresses as $ip ) {
902
        if (!empty($ip) && $this->isValidIpAddress($ip)) {
903
          $ip_address = $ip;
904
          break;
905
        }
906
      }
907
      return $ip_address;
908
    }
909
// OSCOM v2.2rc2a compatibility
910
    function isValidIpAddress($ip_address) {
911
      if ( function_exists('tep_validate_ip_address') ) {