Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
39de6fd5 | 4 | | CiviCRM version 4.6 | |
6a488035 TO |
5 | +--------------------------------------------------------------------+ |
6 | | This file is a part of CiviCRM. | | |
7 | | | | |
8 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
9 | | under the terms of the GNU Affero General Public License | | |
10 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
11 | | | | |
12 | | CiviCRM is distributed in the hope that it will be useful, but | | |
13 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
14 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
15 | | See the GNU Affero General Public License for more details. | | |
16 | | | | |
17 | | You should have received a copy of the GNU Affero General Public | | |
18 | | License and the CiviCRM Licensing Exception along | | |
19 | | with this program; if not, contact CiviCRM LLC | | |
20 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
21 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
22 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
23 | +--------------------------------------------------------------------+ | |
d25dd0ee | 24 | */ |
6a488035 TO |
25 | |
26 | ||
27 | /* | |
28 | * PxPay Functionality Copyright (C) 2008 Lucas Baker, Logistic Information Systems Limited (Logis) | |
29 | * PxAccess Functionality Copyright (C) 2008 Eileen McNaughton | |
30 | * Licensed to CiviCRM under the Academic Free License version 3.0. | |
31 | * | |
32 | * Grateful acknowledgements go to Donald Lobo for invaluable assistance | |
33 | * in creating this payment processor module | |
34 | */ | |
4c6ce474 EM |
35 | |
36 | /** | |
37 | * Class CRM_Core_Payment_PaymentExpressUtils | |
38 | */ | |
6a488035 TO |
39 | class CRM_Core_Payment_PaymentExpressUtils { |
40 | ||
6c786a9b EM |
41 | /** |
42 | * @param $element | |
43 | * @param null $value | |
44 | * | |
45 | * @return string | |
46 | */ | |
00be9182 | 47 | public static function _valueXml($element, $value = NULL) { |
328b8a19 | 48 | $nl = "\n"; |
6a488035 | 49 | |
328b8a19 MR |
50 | if (is_array($element)) { |
51 | $xml = ''; | |
52 | foreach ($element as $elem => $value) { | |
2aa397bc | 53 | $xml .= self::_valueXml($elem, $value); |
328b8a19 MR |
54 | } |
55 | return $xml; | |
6a488035 | 56 | } |
328b8a19 | 57 | return "<" . $element . ">" . $value . "</" . $element . ">" . $nl; |
6a488035 | 58 | } |
6a488035 | 59 | |
6c786a9b EM |
60 | /** |
61 | * @param $xml | |
100fef9d | 62 | * @param string $name |
6c786a9b EM |
63 | * |
64 | * @return mixed | |
65 | */ | |
00be9182 | 66 | public static function _xmlElement($xml, $name) { |
328b8a19 MR |
67 | $value = preg_replace('/.*<' . $name . '[^>]*>(.*)<\/' . $name . '>.*/', '\1', $xml); |
68 | return $value; | |
69 | } | |
6a488035 | 70 | |
6c786a9b EM |
71 | /** |
72 | * @param $xml | |
100fef9d | 73 | * @param string $name |
6c786a9b EM |
74 | * |
75 | * @return mixed|null | |
76 | */ | |
00be9182 | 77 | public static function _xmlAttribute($xml, $name) { |
328b8a19 MR |
78 | $value = preg_replace('/<.*' . $name . '="([^"]*)".*>/', '\1', $xml); |
79 | return $value != $xml ? $value : NULL; | |
80 | } | |
6a488035 | 81 | |
6c786a9b EM |
82 | /** |
83 | * @param $query | |
84 | * @param $url | |
85 | * | |
86 | * @return resource | |
87 | */ | |
00be9182 | 88 | public static function &_initCURL($query, $url) { |
328b8a19 | 89 | $curl = curl_init(); |
6a488035 | 90 | |
328b8a19 MR |
91 | curl_setopt($curl, CURLOPT_URL, $url); |
92 | curl_setopt($curl, CURLOPT_FRESH_CONNECT, TRUE); | |
93 | curl_setopt($curl, CURLOPT_POST, TRUE); | |
94 | curl_setopt($curl, CURLOPT_POSTFIELDS, $query); | |
95 | curl_setopt($curl, CURLOPT_TIMEOUT, 30); | |
96 | curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); | |
97 | if (ini_get('open_basedir') == '' && ini_get('safe_mode') == 'Off') { | |
98 | curl_setopt($curl, CURLOPT_FOLLOWLOCATION, FALSE); | |
99 | } | |
100 | curl_setopt($curl, CURLOPT_HEADER, 0); | |
9120cfd9 | 101 | curl_setopt($curl, CURLOPT_SSLVERSION, 0); |
6a488035 | 102 | |
328b8a19 MR |
103 | if (strtoupper(substr(@php_uname('s'), 0, 3)) === 'WIN') { |
104 | curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'verifySSL')); | |
105 | curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'verifySSL') ? 2 : 0); | |
106 | } | |
107 | return $curl; | |
6a488035 | 108 | } |
6a488035 TO |
109 | |
110 | } |