Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
232624b1 | 4 | | CiviCRM version 4.4 | |
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 | +--------------------------------------------------------------------+ | |
24 | */ | |
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 | */ | |
35 | class CRM_Core_Payment_PaymentExpressUtils { | |
36 | ||
37 | function _valueXml($element, $value = NULL) { | |
38 | $nl = "\n"; | |
39 | ||
40 | if (is_array($element)) { | |
41 | $xml = ''; | |
42 | foreach ($element as $elem => $value) { | |
43 | $xml .= self::_valueXml($elem, $value); | |
44 | } | |
45 | return $xml; | |
46 | } | |
47 | return "<" . $element . ">" . $value . "</" . $element . ">" . $nl; | |
48 | } | |
49 | ||
50 | function _xmlElement($xml, $name) { | |
51 | $value = preg_replace('/.*<' . $name . '[^>]*>(.*)<\/' . $name . '>.*/', '\1', $xml); | |
52 | return $value; | |
53 | } | |
54 | ||
55 | function _xmlAttribute($xml, $name) { | |
56 | $value = preg_replace('/<.*' . $name . '="([^"]*)".*>/', '\1', $xml); | |
57 | return $value != $xml ? $value : NULL; | |
58 | } | |
59 | ||
60 | function &_initCURL($query, $url) { | |
61 | $curl = curl_init(); | |
62 | ||
63 | curl_setopt($curl, CURLOPT_URL, $url); | |
64 | curl_setopt($curl, CURLOPT_FRESH_CONNECT, TRUE); | |
65 | curl_setopt($curl, CURLOPT_POST, TRUE); | |
66 | curl_setopt($curl, CURLOPT_POSTFIELDS, $query); | |
67 | curl_setopt($curl, CURLOPT_POSTFIELDSIZE, 0); | |
68 | curl_setopt($curl, CURLOPT_TIMEOUT, 30); | |
69 | curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE); | |
70 | curl_setopt($curl, CURLOPT_FOLLOWLOCATION, FALSE); | |
71 | curl_setopt($curl, CURLOPT_HEADER, 0); | |
72 | curl_setopt($curl, CURLOPT_SSLVERSION, 3); | |
73 | ||
74 | if (strtoupper(substr(@php_uname('s'), 0, 3)) === 'WIN') { | |
75 | curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'verifySSL')); | |
17c04b52 | 76 | curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'verifySSL') ? 2 : 0); |
6a488035 TO |
77 | } |
78 | return $curl; | |
79 | } | |
80 | ||
81 | } |