Completed
Branch BUG-10412-mcrypt-deprecated (318caa)
by
unknown
11:57 queued 13s
created
caffeinated/payment_methods/Paypal_Pro/EEG_Paypal_Pro.gateway.php 2 patches
Indentation   +587 added lines, -587 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if (! defined('EVENT_ESPRESSO_VERSION')) {
3
-    exit('No direct script access allowed');
3
+	exit('No direct script access allowed');
4 4
 }
5 5
 
6 6
 
@@ -25,591 +25,591 @@  discard block
 block discarded – undo
25 25
 class EEG_Paypal_Pro extends EE_Onsite_Gateway
26 26
 {
27 27
 
28
-    /**
29
-     * @var $_paypal_api_username string
30
-     */
31
-    protected $_username = null;
32
-
33
-    /**
34
-     * @var $_password string
35
-     */
36
-    protected $_password = null;
37
-
38
-    /**
39
-     * @var $_signature string
40
-     */
41
-    protected $_signature = null;
42
-
43
-    /**
44
-     * @var $_credit_card_types array with the keys for credit card types accepted on this account
45
-     */
46
-    protected $_credit_card_types    = null;
47
-
48
-    protected $_currencies_supported = array(
49
-        'USD',
50
-        'GBP',
51
-        'CAD',
52
-        'AUD',
53
-        'BRL',
54
-        'CHF',
55
-        'CZK',
56
-        'DKK',
57
-        'EUR',
58
-        'HKD',
59
-        'HUF',
60
-        'ILS',
61
-        'JPY',
62
-        'MXN',
63
-        'MYR',
64
-        'NOK',
65
-        'NZD',
66
-        'PHP',
67
-        'PLN',
68
-        'SEK',
69
-        'SGD',
70
-        'THB',
71
-        'TRY',
72
-        'TWD',
73
-        'RUB',
74
-    );
75
-
76
-
77
-
78
-    /**
79
-     * @param EEI_Payment $payment
80
-     * @param array       $billing_info {
81
-     * @type string $credit_card
82
-     * @type string $credit_card_type
83
-     * @type string $exp_month always 2 characters
84
-     * @type string $exp_year always 4 characters
85
-     * @type string $cvv
86
-     * }
87
-     * @see      parent::do_direct_payment for more info
88
-     * @return EE_Payment|EEI_Payment
89
-     * @throws EE_Error
90
-     */
91
-    public function do_direct_payment($payment, $billing_info = null)
92
-    {
93
-        $transaction = $payment->transaction();
94
-        if (! $transaction instanceof EEI_Transaction) {
95
-            throw new EE_Error(
96
-                esc_html__('No transaction for payment while paying with PayPal Pro.', 'event_espresso')
97
-            );
98
-        }
99
-        $primary_registrant = $transaction->primary_registration();
100
-        if (! $primary_registrant instanceof EEI_Registration) {
101
-            throw new EE_Error(
102
-                esc_html__(
103
-                    'No primary registration on transaction while paying with PayPal Pro.',
104
-                    'event_espresso'
105
-                )
106
-            );
107
-        }
108
-        $attendee = $primary_registrant->attendee();
109
-        if (! $attendee instanceof EEI_Attendee) {
110
-            throw new EE_Error(
111
-                esc_html__(
112
-                    'No attendee on primary registration while paying with PayPal Pro.',
113
-                    'event_espresso'
114
-                )
115
-            );
116
-        }
117
-        $order_description = substr($this->_format_order_description($payment), 0, 127);
118
-        //charge for the full amount. Show itemized list
119
-        if ($this->_can_easily_itemize_transaction_for($payment)) {
120
-            $item_num = 1;
121
-            $total_line_item = $transaction->total_line_item();
122
-            $order_items = array();
123
-            foreach ($total_line_item->get_items() as $line_item) {
124
-                //ignore line items with a quantity of 0
125
-                if ($line_item->quantity() == 0) {
126
-                    continue;
127
-                }
128
-                $item = array(
129
-                    // Item Name.  127 char max.
130
-                    'l_name'                 => substr(
131
-                        $this->_format_line_item_name($line_item, $payment),
132
-                        0,
133
-                        127
134
-                    ),
135
-                    // Item description.  127 char max.
136
-                    'l_desc'                 => substr(
137
-                        $this->_format_line_item_desc($line_item, $payment),
138
-                        0,
139
-                        127
140
-                    ),
141
-                    // Cost of individual item.
142
-                    'l_amt'                  => $line_item->unit_price(),
143
-                    // Item Number.  127 char max.
144
-                    'l_number'               => $item_num++,
145
-                    // Item quantity.  Must be any positive integer.
146
-                    'l_qty'                  => $line_item->quantity(),
147
-                    // Item's sales tax amount.
148
-                    'l_taxamt'               => '',
149
-                    // eBay auction number of item.
150
-                    'l_ebayitemnumber'       => '',
151
-                    // eBay transaction ID of purchased item.
152
-                    'l_ebayitemauctiontxnid' => '',
153
-                    // eBay order ID for the item.
154
-                    'l_ebayitemorderid'      => '',
155
-                );
156
-                // add to array of all items
157
-                array_push($order_items, $item);
158
-            }
159
-            $item_amount = $total_line_item->get_items_total();
160
-            $tax_amount = $total_line_item->get_total_tax();
161
-        } else {
162
-            $order_items = array();
163
-            $item_amount = $payment->amount();
164
-            $tax_amount = 0;
165
-            array_push($order_items, array(
166
-                // Item Name.  127 char max.
167
-                'l_name'   => substr(
168
-                    $this->_format_partial_payment_line_item_name($payment),
169
-                    0,
170
-                    127
171
-                ),
172
-                // Item description.  127 char max.
173
-                'l_desc'   => substr(
174
-                    $this->_format_partial_payment_line_item_desc($payment),
175
-                    0,
176
-                    127
177
-                ),
178
-                // Cost of individual item.
179
-                'l_amt'    => $payment->amount(),
180
-                // Item Number.  127 char max.
181
-                'l_number' => 1,
182
-                // Item quantity.  Must be any positive integer.
183
-                'l_qty'    => 1,
184
-            ));
185
-        }
186
-        // Populate data arrays with order data.
187
-        $DPFields = array(
188
-            // How you want to obtain payment ?
189
-            // Authorization indicates the payment is a basic auth subject to settlement with Auth & Capture.
190
-            // Sale indicates that this is a final sale for which you are requesting payment.  Default is Sale.
191
-            'paymentaction'    => 'Sale',
192
-            // Required.  IP address of the payer's browser.
193
-            'ipaddress'        => $_SERVER['REMOTE_ADDR'],
194
-            // Flag to determine whether you want the results returned by FMF.  1 or 0.  Default is 0.
195
-            'returnfmfdetails' => '1',
196
-        );
197
-        $CCDetails = array(
198
-            // Required. Type of credit card.  Visa, MasterCard, Discover, Amex, Maestro, Solo.
199
-            // If Maestro or Solo, the currency code must be GBP.
200
-            //  In addition, either start date or issue number must be specified.
201
-            'creditcardtype' => $billing_info['credit_card_type'],
202
-            // Required.  Credit card number.  No spaces or punctuation.
203
-            'acct'           => $billing_info['credit_card'],
204
-            // Required.  Credit card expiration date.  Format is MMYYYY
205
-            'expdate'        => $billing_info['exp_month'] . $billing_info['exp_year'],
206
-            // Requirements determined by your PayPal account settings.  Security digits for credit card.
207
-            'cvv2'           => $billing_info['cvv'],
208
-        );
209
-        $PayerInfo = array(
210
-            // Email address of payer.
211
-            'email'       => $billing_info['email'],
212
-            // Unique PayPal customer ID for payer.
213
-            'payerid'     => '',
214
-            // Status of payer.  Values are verified or unverified
215
-            'payerstatus' => '',
216
-            // Payer's business name.
217
-            'business'    => '',
218
-        );
219
-        $PayerName = array(
220
-            // Payer's salutation.  20 char max.
221
-            'salutation' => '',
222
-            // Payer's first name.  25 char max.
223
-            'firstname'  => substr($billing_info['first_name'], 0, 25),
224
-            // Payer's middle name.  25 char max.
225
-            'middlename' => '',
226
-            // Payer's last name.  25 char max.
227
-            'lastname'   => substr($billing_info['last_name'], 0, 25),
228
-            // Payer's suffix.  12 char max.
229
-            'suffix'     => '',
230
-        );
231
-        $BillingAddress = array(
232
-            // Required.  First street address.
233
-            'street'      => $billing_info['address'],
234
-            // Second street address.
235
-            'street2'     => $billing_info['address2'],
236
-            // Required.  Name of City.
237
-            'city'        => $billing_info['city'],
238
-            // Required. Name of State or Province.
239
-            'state'       => substr($billing_info['state'], 0, 40),
240
-            // Required.  Country code.
241
-            'countrycode' => $billing_info['country'],
242
-            // Required.  Postal code of payer.
243
-            'zip'         => $billing_info['zip'],
244
-        );
245
-        //check if the registration info contains the needed fields for paypal pro
246
-        //(see https://developer.paypal.com/docs/classic/api/merchant/DoDirectPayment_API_Operation_NVP/)
247
-        if ($attendee->address() && $attendee->city() && $attendee->country_ID()) {
248
-            $use_registration_address_info = true;
249
-        } else {
250
-            $use_registration_address_info = false;
251
-        }
252
-        //so if the attendee has enough data to fill out PayPal Pro's shipping info, use it.
253
-        // If not, use the billing info again
254
-        $ShippingAddress = array(
255
-            'shiptoname'     => substr($use_registration_address_info
256
-                ? $attendee->full_name()
257
-                : $billing_info['first_name'] . ' ' . $billing_info['last_name'], 0, 32),
258
-            'shiptostreet'   => substr($use_registration_address_info
259
-                ? $attendee->address()
260
-                : $billing_info['address'], 0, 100),
261
-            'shiptostreet2'  => substr($use_registration_address_info
262
-                ? $attendee->address2() : $billing_info['address2'], 0, 100),
263
-            'shiptocity'     => substr($use_registration_address_info
264
-                ? $attendee->city()
265
-                : $billing_info['city'], 0, 40),
266
-            'state'          => substr($use_registration_address_info
267
-                ? $attendee->state_name()
268
-                : $billing_info['state'], 0, 40),
269
-            'shiptocountry'  => $use_registration_address_info
270
-                ? $attendee->country_ID()
271
-                : $billing_info['country'],
272
-            'shiptozip'      => substr($use_registration_address_info
273
-                ? $attendee->zip()
274
-                : $billing_info['zip'], 0, 20),
275
-            'shiptophonenum' => substr($use_registration_address_info
276
-                ? $attendee->phone()
277
-                : $billing_info['phone'], 0, 20),
278
-        );
279
-        $PaymentDetails = array(
280
-            // Required.  Total amount of order, including shipping, handling, and tax.
281
-            'amt'          => $this->format_currency($payment->amount()),
282
-            // Required.  Three-letter currency code.  Default is USD.
283
-            'currencycode' => $payment->currency_code(),
284
-            // Required if you include itemized cart details. (L_AMTn, etc.)
285
-            //Subtotal of items not including S&H, or tax.
286
-            'itemamt'      => $this->format_currency($item_amount),//
287
-            // Total shipping costs for the order.  If you specify shippingamt, you must also specify itemamt.
288
-            'shippingamt'  => '',
289
-            // Total handling costs for the order.  If you specify handlingamt, you must also specify itemamt.
290
-            'handlingamt'  => '',
291
-            // Required if you specify itemized cart tax details.
292
-            // Sum of tax for all items on the order.  Total sales tax.
293
-            'taxamt'       => $this->format_currency($tax_amount),
294
-            // Description of the order the customer is purchasing.  127 char max.
295
-            'desc'         => $order_description,
296
-            // Free-form field for your own use.  256 char max.
297
-            'custom'       => $primary_registrant ? $primary_registrant->ID() : '',
298
-            // Your own invoice or tracking number
299
-            'invnum'       => wp_generate_password(12, false),//$transaction->ID(),
300
-            // URL for receiving Instant Payment Notifications.  This overrides what your profile is set to use.
301
-            'notifyurl'    => '',
302
-            'buttonsource' => 'EventEspresso_SP',//EE will blow up if you change this
303
-        );
304
-        // Wrap all data arrays into a single, "master" array which will be passed into the class function.
305
-        $PayPalRequestData = array(
306
-            'DPFields'        => $DPFields,
307
-            'CCDetails'       => $CCDetails,
308
-            'PayerInfo'       => $PayerInfo,
309
-            'PayerName'       => $PayerName,
310
-            'BillingAddress'  => $BillingAddress,
311
-            'ShippingAddress' => $ShippingAddress,
312
-            'PaymentDetails'  => $PaymentDetails,
313
-            'OrderItems'      => $order_items,
314
-        );
315
-        $this->_log_clean_request($PayPalRequestData, $payment);
316
-        try {
317
-            $PayPalResult = $this->prep_and_curl_request($PayPalRequestData);
318
-            //remove PCI-sensitive data so it doesn't get stored
319
-            $PayPalResult = $this->_log_clean_response($PayPalResult, $payment);
320
-            $message = isset($PayPalResult['L_LONGMESSAGE0']) ? $PayPalResult['L_LONGMESSAGE0'] : $PayPalResult['ACK'];
321
-            if (empty($PayPalResult['RAWRESPONSE'])) {
322
-                $payment->set_status($this->_pay_model->failed_status());
323
-                $payment->set_gateway_response(__('No response received from Paypal Pro', 'event_espresso'));
324
-                $payment->set_details($PayPalResult);
325
-            } else {
326
-                if ($this->_APICallSuccessful($PayPalResult)) {
327
-                    $payment->set_status($this->_pay_model->approved_status());
328
-                } else {
329
-                    $payment->set_status($this->_pay_model->declined_status());
330
-                }
331
-                //make sure we interpret the AMT as a float, not an international string
332
-                // (where periods are thousand separators)
333
-                $payment->set_amount(isset($PayPalResult['AMT']) ? floatval($PayPalResult['AMT']) : 0);
334
-                $payment->set_gateway_response($message);
335
-                $payment->set_txn_id_chq_nmbr(isset($PayPalResult['TRANSACTIONID'])
336
-                    ? $PayPalResult['TRANSACTIONID']
337
-                    : null);
338
-                $primary_registration_code = $primary_registrant instanceof EE_Registration
339
-                    ? $primary_registrant->reg_code()
340
-                    : '';
341
-                $payment->set_extra_accntng($primary_registration_code);
342
-                $payment->set_details($PayPalResult);
343
-            }
344
-        } catch (Exception $e) {
345
-            $payment->set_status($this->_pay_model->failed_status());
346
-            $payment->set_gateway_response($e->getMessage());
347
-        }
348
-        //$payment->set_status( $this->_pay_model->declined_status() );
349
-        //$payment->set_gateway_response( '' );
350
-        return $payment;
351
-    }
352
-
353
-
354
-
355
-    /**
356
-     * CLeans out sensitive CC data and then logs it, and returns the cleaned request
357
-     *
358
-     * @param array       $request
359
-     * @param EEI_Payment $payment
360
-     * @return void
361
-     */
362
-    private function _log_clean_request($request, $payment)
363
-    {
364
-        $cleaned_request_data = $request;
365
-        unset($cleaned_request_data['CCDetails']['acct']);
366
-        unset($cleaned_request_data['CCDetails']['cvv2']);
367
-        unset($cleaned_request_data['CCDetails']['expdate']);
368
-        $this->log(array('Paypal Request' => $cleaned_request_data), $payment);
369
-    }
370
-
371
-
372
-
373
-    /**
374
-     * Cleans the response, logs it, and returns it
375
-     *
376
-     * @param array       $response
377
-     * @param EEI_Payment $payment
378
-     * @return array cleaned
379
-     */
380
-    private function _log_clean_response($response, $payment)
381
-    {
382
-        unset($response['REQUESTDATA']['CREDITCARDTYPE']);
383
-        unset($response['REQUESTDATA']['ACCT']);
384
-        unset($response['REQUESTDATA']['EXPDATE']);
385
-        unset($response['REQUESTDATA']['CVV2']);
386
-        unset($response['RAWREQUEST']);
387
-        $this->log(array('Paypal Response' => $response), $payment);
388
-        return $response;
389
-    }
390
-
391
-
392
-
393
-    /**
394
-     * @param $DataArray
395
-     * @return array
396
-     */
397
-    private function prep_and_curl_request($DataArray)
398
-    {
399
-        // Create empty holders for each portion of the NVP string
400
-        $DPFieldsNVP = '&METHOD=DoDirectPayment&BUTTONSOURCE=AngellEYE_PHP_Class_DDP';
401
-        $CCDetailsNVP = '';
402
-        $PayerInfoNVP = '';
403
-        $PayerNameNVP = '';
404
-        $BillingAddressNVP = '';
405
-        $ShippingAddressNVP = '';
406
-        $PaymentDetailsNVP = '';
407
-        $OrderItemsNVP = '';
408
-        $Secure3DNVP = '';
409
-        // DP Fields
410
-        $DPFields = isset($DataArray['DPFields']) ? $DataArray['DPFields'] : array();
411
-        foreach ($DPFields as $DPFieldsVar => $DPFieldsVal) {
412
-            $DPFieldsNVP .= '&' . strtoupper($DPFieldsVar) . '=' . urlencode($DPFieldsVal);
413
-        }
414
-        // CC Details Fields
415
-        $CCDetails = isset($DataArray['CCDetails']) ? $DataArray['CCDetails'] : array();
416
-        foreach ($CCDetails as $CCDetailsVar => $CCDetailsVal) {
417
-            $CCDetailsNVP .= '&' . strtoupper($CCDetailsVar) . '=' . urlencode($CCDetailsVal);
418
-        }
419
-        // PayerInfo Type Fields
420
-        $PayerInfo = isset($DataArray['PayerInfo']) ? $DataArray['PayerInfo'] : array();
421
-        foreach ($PayerInfo as $PayerInfoVar => $PayerInfoVal) {
422
-            $PayerInfoNVP .= '&' . strtoupper($PayerInfoVar) . '=' . urlencode($PayerInfoVal);
423
-        }
424
-        // Payer Name Fields
425
-        $PayerName = isset($DataArray['PayerName']) ? $DataArray['PayerName'] : array();
426
-        foreach ($PayerName as $PayerNameVar => $PayerNameVal) {
427
-            $PayerNameNVP .= '&' . strtoupper($PayerNameVar) . '=' . urlencode($PayerNameVal);
428
-        }
429
-        // Address Fields (Billing)
430
-        $BillingAddress = isset($DataArray['BillingAddress']) ? $DataArray['BillingAddress'] : array();
431
-        foreach ($BillingAddress as $BillingAddressVar => $BillingAddressVal) {
432
-            $BillingAddressNVP .= '&' . strtoupper($BillingAddressVar) . '=' . urlencode($BillingAddressVal);
433
-        }
434
-        // Payment Details Type Fields
435
-        $PaymentDetails = isset($DataArray['PaymentDetails']) ? $DataArray['PaymentDetails'] : array();
436
-        foreach ($PaymentDetails as $PaymentDetailsVar => $PaymentDetailsVal) {
437
-            $PaymentDetailsNVP .= '&' . strtoupper($PaymentDetailsVar) . '=' . urlencode($PaymentDetailsVal);
438
-        }
439
-        // Payment Details Item Type Fields
440
-        $OrderItems = isset($DataArray['OrderItems']) ? $DataArray['OrderItems'] : array();
441
-        $n = 0;
442
-        foreach ($OrderItems as $OrderItemsVar => $OrderItemsVal) {
443
-            $CurrentItem = $OrderItems[$OrderItemsVar];
444
-            foreach ($CurrentItem as $CurrentItemVar => $CurrentItemVal) {
445
-                $OrderItemsNVP .= '&' . strtoupper($CurrentItemVar) . $n . '=' . urlencode($CurrentItemVal);
446
-            }
447
-            $n++;
448
-        }
449
-        // Ship To Address Fields
450
-        $ShippingAddress = isset($DataArray['ShippingAddress']) ? $DataArray['ShippingAddress'] : array();
451
-        foreach ($ShippingAddress as $ShippingAddressVar => $ShippingAddressVal) {
452
-            $ShippingAddressNVP .= '&' . strtoupper($ShippingAddressVar) . '=' . urlencode($ShippingAddressVal);
453
-        }
454
-        // 3D Secure Fields
455
-        $Secure3D = isset($DataArray['Secure3D']) ? $DataArray['Secure3D'] : array();
456
-        foreach ($Secure3D as $Secure3DVar => $Secure3DVal) {
457
-            $Secure3DNVP .= '&' . strtoupper($Secure3DVar) . '=' . urlencode($Secure3DVal);
458
-        }
459
-        // Now that we have each chunk we need to go ahead and append them all together for our entire NVP string
460
-        $NVPRequest = 'USER='
461
-                      . $this->_username
462
-                      . '&PWD='
463
-                      . $this->_password
464
-                      . '&VERSION=64.0'
465
-                      . '&SIGNATURE='
466
-                      . $this->_signature
467
-                      . $DPFieldsNVP
468
-                      . $CCDetailsNVP
469
-                      . $PayerInfoNVP
470
-                      . $PayerNameNVP
471
-                      . $BillingAddressNVP
472
-                      . $PaymentDetailsNVP
473
-                      . $OrderItemsNVP
474
-                      . $ShippingAddressNVP
475
-                      . $Secure3DNVP;
476
-        $NVPResponse = $this->_CURLRequest($NVPRequest);
477
-        $NVPRequestArray = $this->_NVPToArray($NVPRequest);
478
-        $NVPResponseArray = $this->_NVPToArray($NVPResponse);
479
-        $Errors = $this->_GetErrors($NVPResponseArray);
480
-        $NVPResponseArray['ERRORS'] = $Errors;
481
-        $NVPResponseArray['REQUESTDATA'] = $NVPRequestArray;
482
-        $NVPResponseArray['RAWREQUEST'] = $NVPRequest;
483
-        $NVPResponseArray['RAWRESPONSE'] = $NVPResponse;
484
-        return $NVPResponseArray;
485
-    }
486
-
487
-
488
-
489
-    /**
490
-     * @param $Request
491
-     * @return mixed
492
-     */
493
-    private function _CURLRequest($Request)
494
-    {
495
-        $EndPointURL = $this->_debug_mode ? 'https://api-3t.sandbox.paypal.com/nvp' : 'https://api-3t.paypal.com/nvp';
496
-        $curl = curl_init();
497
-        curl_setopt($curl, CURLOPT_VERBOSE, apply_filters('FHEE__EEG_Paypal_Pro__CurlRequest__CURLOPT_VERBOSE', true));
498
-        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
499
-        curl_setopt($curl, CURLOPT_TIMEOUT, 60);
500
-        curl_setopt($curl, CURLOPT_URL, $EndPointURL);
501
-        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
502
-        curl_setopt($curl, CURLOPT_POSTFIELDS, $Request);
503
-        curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
504
-        //execute the curl POST
505
-        $Response = curl_exec($curl);
506
-        curl_close($curl);
507
-        return $Response;
508
-    }
509
-
510
-
511
-
512
-    /**
513
-     * @param $NVPString
514
-     * @return array
515
-     */
516
-    private function _NVPToArray($NVPString)
517
-    {
518
-        // prepare responses into array
519
-        $proArray = array();
520
-        while (strlen($NVPString)) {
521
-            // name
522
-            $keypos = strpos($NVPString, '=');
523
-            $keyval = substr($NVPString, 0, $keypos);
524
-            // value
525
-            $valuepos = strpos($NVPString, '&') ? strpos($NVPString, '&') : strlen($NVPString);
526
-            $valval = substr($NVPString, $keypos + 1, $valuepos - $keypos - 1);
527
-            // decoding the response
528
-            $proArray[$keyval] = urldecode($valval);
529
-            $NVPString = substr($NVPString, $valuepos + 1, strlen($NVPString));
530
-        }
531
-        return $proArray;
532
-    }
533
-
534
-
535
-
536
-    /**
537
-     * @param array $PayPalResult
538
-     * @return bool
539
-     */
540
-    private function _APICallSuccessful($PayPalResult)
541
-    {
542
-        $approved = false;
543
-        // check main response message from PayPal
544
-        if (isset($PayPalResult['ACK']) && ! empty($PayPalResult['ACK'])) {
545
-            $ack = strtoupper($PayPalResult['ACK']);
546
-            $approved = ($ack == 'SUCCESS' || $ack == 'SUCCESSWITHWARNING' || $ack == 'PARTIALSUCCESS') ? true : false;
547
-        }
548
-        return $approved;
549
-    }
550
-
551
-
552
-
553
-    /**
554
-     * @param $DataArray
555
-     * @return array
556
-     */
557
-    private function _GetErrors($DataArray)
558
-    {
559
-        $Errors = array();
560
-        $n = 0;
561
-        while (isset($DataArray['L_ERRORCODE' . $n . ''])) {
562
-            $LErrorCode = isset($DataArray['L_ERRORCODE' . $n . '']) ? $DataArray['L_ERRORCODE' . $n . ''] : '';
563
-            $LShortMessage = isset($DataArray['L_SHORTMESSAGE' . $n . ''])
564
-                ? $DataArray['L_SHORTMESSAGE' . $n . '']
565
-                : '';
566
-            $LLongMessage = isset($DataArray['L_LONGMESSAGE' . $n . ''])
567
-                ? $DataArray['L_LONGMESSAGE' . $n . '']
568
-                : '';
569
-            $LSeverityCode = isset($DataArray['L_SEVERITYCODE' . $n . ''])
570
-                ? $DataArray['L_SEVERITYCODE' . $n . '']
571
-                : '';
572
-            $CurrentItem = array(
573
-                'L_ERRORCODE'    => $LErrorCode,
574
-                'L_SHORTMESSAGE' => $LShortMessage,
575
-                'L_LONGMESSAGE'  => $LLongMessage,
576
-                'L_SEVERITYCODE' => $LSeverityCode,
577
-            );
578
-            array_push($Errors, $CurrentItem);
579
-            $n++;
580
-        }
581
-        return $Errors;
582
-    }
583
-
584
-
585
-
586
-    /**
587
-     *        nothing to see here...  move along....
588
-     *
589
-     * @access protected
590
-     * @param $Errors
591
-     * @return string
592
-     */
593
-    private function _DisplayErrors($Errors)
594
-    {
595
-        $error = '';
596
-        foreach ($Errors as $ErrorVar => $ErrorVal) {
597
-            $CurrentError = $Errors[$ErrorVar];
598
-            foreach ($CurrentError as $CurrentErrorVar => $CurrentErrorVal) {
599
-                $CurrentVarName = '';
600
-                if ($CurrentErrorVar == 'L_ERRORCODE') {
601
-                    $CurrentVarName = 'Error Code';
602
-                } elseif ($CurrentErrorVar == 'L_SHORTMESSAGE') {
603
-                    $CurrentVarName = 'Short Message';
604
-                } elseif ($CurrentErrorVar == 'L_LONGMESSAGE') {
605
-                    $CurrentVarName = 'Long Message';
606
-                } elseif ($CurrentErrorVar == 'L_SEVERITYCODE') {
607
-                    $CurrentVarName = 'Severity Code';
608
-                }
609
-                $error .= '<br />' . $CurrentVarName . ': ' . $CurrentErrorVal;
610
-            }
611
-        }
612
-        return $error;
613
-    }
28
+	/**
29
+	 * @var $_paypal_api_username string
30
+	 */
31
+	protected $_username = null;
32
+
33
+	/**
34
+	 * @var $_password string
35
+	 */
36
+	protected $_password = null;
37
+
38
+	/**
39
+	 * @var $_signature string
40
+	 */
41
+	protected $_signature = null;
42
+
43
+	/**
44
+	 * @var $_credit_card_types array with the keys for credit card types accepted on this account
45
+	 */
46
+	protected $_credit_card_types    = null;
47
+
48
+	protected $_currencies_supported = array(
49
+		'USD',
50
+		'GBP',
51
+		'CAD',
52
+		'AUD',
53
+		'BRL',
54
+		'CHF',
55
+		'CZK',
56
+		'DKK',
57
+		'EUR',
58
+		'HKD',
59
+		'HUF',
60
+		'ILS',
61
+		'JPY',
62
+		'MXN',
63
+		'MYR',
64
+		'NOK',
65
+		'NZD',
66
+		'PHP',
67
+		'PLN',
68
+		'SEK',
69
+		'SGD',
70
+		'THB',
71
+		'TRY',
72
+		'TWD',
73
+		'RUB',
74
+	);
75
+
76
+
77
+
78
+	/**
79
+	 * @param EEI_Payment $payment
80
+	 * @param array       $billing_info {
81
+	 * @type string $credit_card
82
+	 * @type string $credit_card_type
83
+	 * @type string $exp_month always 2 characters
84
+	 * @type string $exp_year always 4 characters
85
+	 * @type string $cvv
86
+	 * }
87
+	 * @see      parent::do_direct_payment for more info
88
+	 * @return EE_Payment|EEI_Payment
89
+	 * @throws EE_Error
90
+	 */
91
+	public function do_direct_payment($payment, $billing_info = null)
92
+	{
93
+		$transaction = $payment->transaction();
94
+		if (! $transaction instanceof EEI_Transaction) {
95
+			throw new EE_Error(
96
+				esc_html__('No transaction for payment while paying with PayPal Pro.', 'event_espresso')
97
+			);
98
+		}
99
+		$primary_registrant = $transaction->primary_registration();
100
+		if (! $primary_registrant instanceof EEI_Registration) {
101
+			throw new EE_Error(
102
+				esc_html__(
103
+					'No primary registration on transaction while paying with PayPal Pro.',
104
+					'event_espresso'
105
+				)
106
+			);
107
+		}
108
+		$attendee = $primary_registrant->attendee();
109
+		if (! $attendee instanceof EEI_Attendee) {
110
+			throw new EE_Error(
111
+				esc_html__(
112
+					'No attendee on primary registration while paying with PayPal Pro.',
113
+					'event_espresso'
114
+				)
115
+			);
116
+		}
117
+		$order_description = substr($this->_format_order_description($payment), 0, 127);
118
+		//charge for the full amount. Show itemized list
119
+		if ($this->_can_easily_itemize_transaction_for($payment)) {
120
+			$item_num = 1;
121
+			$total_line_item = $transaction->total_line_item();
122
+			$order_items = array();
123
+			foreach ($total_line_item->get_items() as $line_item) {
124
+				//ignore line items with a quantity of 0
125
+				if ($line_item->quantity() == 0) {
126
+					continue;
127
+				}
128
+				$item = array(
129
+					// Item Name.  127 char max.
130
+					'l_name'                 => substr(
131
+						$this->_format_line_item_name($line_item, $payment),
132
+						0,
133
+						127
134
+					),
135
+					// Item description.  127 char max.
136
+					'l_desc'                 => substr(
137
+						$this->_format_line_item_desc($line_item, $payment),
138
+						0,
139
+						127
140
+					),
141
+					// Cost of individual item.
142
+					'l_amt'                  => $line_item->unit_price(),
143
+					// Item Number.  127 char max.
144
+					'l_number'               => $item_num++,
145
+					// Item quantity.  Must be any positive integer.
146
+					'l_qty'                  => $line_item->quantity(),
147
+					// Item's sales tax amount.
148
+					'l_taxamt'               => '',
149
+					// eBay auction number of item.
150
+					'l_ebayitemnumber'       => '',
151
+					// eBay transaction ID of purchased item.
152
+					'l_ebayitemauctiontxnid' => '',
153
+					// eBay order ID for the item.
154
+					'l_ebayitemorderid'      => '',
155
+				);
156
+				// add to array of all items
157
+				array_push($order_items, $item);
158
+			}
159
+			$item_amount = $total_line_item->get_items_total();
160
+			$tax_amount = $total_line_item->get_total_tax();
161
+		} else {
162
+			$order_items = array();
163
+			$item_amount = $payment->amount();
164
+			$tax_amount = 0;
165
+			array_push($order_items, array(
166
+				// Item Name.  127 char max.
167
+				'l_name'   => substr(
168
+					$this->_format_partial_payment_line_item_name($payment),
169
+					0,
170
+					127
171
+				),
172
+				// Item description.  127 char max.
173
+				'l_desc'   => substr(
174
+					$this->_format_partial_payment_line_item_desc($payment),
175
+					0,
176
+					127
177
+				),
178
+				// Cost of individual item.
179
+				'l_amt'    => $payment->amount(),
180
+				// Item Number.  127 char max.
181
+				'l_number' => 1,
182
+				// Item quantity.  Must be any positive integer.
183
+				'l_qty'    => 1,
184
+			));
185
+		}
186
+		// Populate data arrays with order data.
187
+		$DPFields = array(
188
+			// How you want to obtain payment ?
189
+			// Authorization indicates the payment is a basic auth subject to settlement with Auth & Capture.
190
+			// Sale indicates that this is a final sale for which you are requesting payment.  Default is Sale.
191
+			'paymentaction'    => 'Sale',
192
+			// Required.  IP address of the payer's browser.
193
+			'ipaddress'        => $_SERVER['REMOTE_ADDR'],
194
+			// Flag to determine whether you want the results returned by FMF.  1 or 0.  Default is 0.
195
+			'returnfmfdetails' => '1',
196
+		);
197
+		$CCDetails = array(
198
+			// Required. Type of credit card.  Visa, MasterCard, Discover, Amex, Maestro, Solo.
199
+			// If Maestro or Solo, the currency code must be GBP.
200
+			//  In addition, either start date or issue number must be specified.
201
+			'creditcardtype' => $billing_info['credit_card_type'],
202
+			// Required.  Credit card number.  No spaces or punctuation.
203
+			'acct'           => $billing_info['credit_card'],
204
+			// Required.  Credit card expiration date.  Format is MMYYYY
205
+			'expdate'        => $billing_info['exp_month'] . $billing_info['exp_year'],
206
+			// Requirements determined by your PayPal account settings.  Security digits for credit card.
207
+			'cvv2'           => $billing_info['cvv'],
208
+		);
209
+		$PayerInfo = array(
210
+			// Email address of payer.
211
+			'email'       => $billing_info['email'],
212
+			// Unique PayPal customer ID for payer.
213
+			'payerid'     => '',
214
+			// Status of payer.  Values are verified or unverified
215
+			'payerstatus' => '',
216
+			// Payer's business name.
217
+			'business'    => '',
218
+		);
219
+		$PayerName = array(
220
+			// Payer's salutation.  20 char max.
221
+			'salutation' => '',
222
+			// Payer's first name.  25 char max.
223
+			'firstname'  => substr($billing_info['first_name'], 0, 25),
224
+			// Payer's middle name.  25 char max.
225
+			'middlename' => '',
226
+			// Payer's last name.  25 char max.
227
+			'lastname'   => substr($billing_info['last_name'], 0, 25),
228
+			// Payer's suffix.  12 char max.
229
+			'suffix'     => '',
230
+		);
231
+		$BillingAddress = array(
232
+			// Required.  First street address.
233
+			'street'      => $billing_info['address'],
234
+			// Second street address.
235
+			'street2'     => $billing_info['address2'],
236
+			// Required.  Name of City.
237
+			'city'        => $billing_info['city'],
238
+			// Required. Name of State or Province.
239
+			'state'       => substr($billing_info['state'], 0, 40),
240
+			// Required.  Country code.
241
+			'countrycode' => $billing_info['country'],
242
+			// Required.  Postal code of payer.
243
+			'zip'         => $billing_info['zip'],
244
+		);
245
+		//check if the registration info contains the needed fields for paypal pro
246
+		//(see https://developer.paypal.com/docs/classic/api/merchant/DoDirectPayment_API_Operation_NVP/)
247
+		if ($attendee->address() && $attendee->city() && $attendee->country_ID()) {
248
+			$use_registration_address_info = true;
249
+		} else {
250
+			$use_registration_address_info = false;
251
+		}
252
+		//so if the attendee has enough data to fill out PayPal Pro's shipping info, use it.
253
+		// If not, use the billing info again
254
+		$ShippingAddress = array(
255
+			'shiptoname'     => substr($use_registration_address_info
256
+				? $attendee->full_name()
257
+				: $billing_info['first_name'] . ' ' . $billing_info['last_name'], 0, 32),
258
+			'shiptostreet'   => substr($use_registration_address_info
259
+				? $attendee->address()
260
+				: $billing_info['address'], 0, 100),
261
+			'shiptostreet2'  => substr($use_registration_address_info
262
+				? $attendee->address2() : $billing_info['address2'], 0, 100),
263
+			'shiptocity'     => substr($use_registration_address_info
264
+				? $attendee->city()
265
+				: $billing_info['city'], 0, 40),
266
+			'state'          => substr($use_registration_address_info
267
+				? $attendee->state_name()
268
+				: $billing_info['state'], 0, 40),
269
+			'shiptocountry'  => $use_registration_address_info
270
+				? $attendee->country_ID()
271
+				: $billing_info['country'],
272
+			'shiptozip'      => substr($use_registration_address_info
273
+				? $attendee->zip()
274
+				: $billing_info['zip'], 0, 20),
275
+			'shiptophonenum' => substr($use_registration_address_info
276
+				? $attendee->phone()
277
+				: $billing_info['phone'], 0, 20),
278
+		);
279
+		$PaymentDetails = array(
280
+			// Required.  Total amount of order, including shipping, handling, and tax.
281
+			'amt'          => $this->format_currency($payment->amount()),
282
+			// Required.  Three-letter currency code.  Default is USD.
283
+			'currencycode' => $payment->currency_code(),
284
+			// Required if you include itemized cart details. (L_AMTn, etc.)
285
+			//Subtotal of items not including S&H, or tax.
286
+			'itemamt'      => $this->format_currency($item_amount),//
287
+			// Total shipping costs for the order.  If you specify shippingamt, you must also specify itemamt.
288
+			'shippingamt'  => '',
289
+			// Total handling costs for the order.  If you specify handlingamt, you must also specify itemamt.
290
+			'handlingamt'  => '',
291
+			// Required if you specify itemized cart tax details.
292
+			// Sum of tax for all items on the order.  Total sales tax.
293
+			'taxamt'       => $this->format_currency($tax_amount),
294
+			// Description of the order the customer is purchasing.  127 char max.
295
+			'desc'         => $order_description,
296
+			// Free-form field for your own use.  256 char max.
297
+			'custom'       => $primary_registrant ? $primary_registrant->ID() : '',
298
+			// Your own invoice or tracking number
299
+			'invnum'       => wp_generate_password(12, false),//$transaction->ID(),
300
+			// URL for receiving Instant Payment Notifications.  This overrides what your profile is set to use.
301
+			'notifyurl'    => '',
302
+			'buttonsource' => 'EventEspresso_SP',//EE will blow up if you change this
303
+		);
304
+		// Wrap all data arrays into a single, "master" array which will be passed into the class function.
305
+		$PayPalRequestData = array(
306
+			'DPFields'        => $DPFields,
307
+			'CCDetails'       => $CCDetails,
308
+			'PayerInfo'       => $PayerInfo,
309
+			'PayerName'       => $PayerName,
310
+			'BillingAddress'  => $BillingAddress,
311
+			'ShippingAddress' => $ShippingAddress,
312
+			'PaymentDetails'  => $PaymentDetails,
313
+			'OrderItems'      => $order_items,
314
+		);
315
+		$this->_log_clean_request($PayPalRequestData, $payment);
316
+		try {
317
+			$PayPalResult = $this->prep_and_curl_request($PayPalRequestData);
318
+			//remove PCI-sensitive data so it doesn't get stored
319
+			$PayPalResult = $this->_log_clean_response($PayPalResult, $payment);
320
+			$message = isset($PayPalResult['L_LONGMESSAGE0']) ? $PayPalResult['L_LONGMESSAGE0'] : $PayPalResult['ACK'];
321
+			if (empty($PayPalResult['RAWRESPONSE'])) {
322
+				$payment->set_status($this->_pay_model->failed_status());
323
+				$payment->set_gateway_response(__('No response received from Paypal Pro', 'event_espresso'));
324
+				$payment->set_details($PayPalResult);
325
+			} else {
326
+				if ($this->_APICallSuccessful($PayPalResult)) {
327
+					$payment->set_status($this->_pay_model->approved_status());
328
+				} else {
329
+					$payment->set_status($this->_pay_model->declined_status());
330
+				}
331
+				//make sure we interpret the AMT as a float, not an international string
332
+				// (where periods are thousand separators)
333
+				$payment->set_amount(isset($PayPalResult['AMT']) ? floatval($PayPalResult['AMT']) : 0);
334
+				$payment->set_gateway_response($message);
335
+				$payment->set_txn_id_chq_nmbr(isset($PayPalResult['TRANSACTIONID'])
336
+					? $PayPalResult['TRANSACTIONID']
337
+					: null);
338
+				$primary_registration_code = $primary_registrant instanceof EE_Registration
339
+					? $primary_registrant->reg_code()
340
+					: '';
341
+				$payment->set_extra_accntng($primary_registration_code);
342
+				$payment->set_details($PayPalResult);
343
+			}
344
+		} catch (Exception $e) {
345
+			$payment->set_status($this->_pay_model->failed_status());
346
+			$payment->set_gateway_response($e->getMessage());
347
+		}
348
+		//$payment->set_status( $this->_pay_model->declined_status() );
349
+		//$payment->set_gateway_response( '' );
350
+		return $payment;
351
+	}
352
+
353
+
354
+
355
+	/**
356
+	 * CLeans out sensitive CC data and then logs it, and returns the cleaned request
357
+	 *
358
+	 * @param array       $request
359
+	 * @param EEI_Payment $payment
360
+	 * @return void
361
+	 */
362
+	private function _log_clean_request($request, $payment)
363
+	{
364
+		$cleaned_request_data = $request;
365
+		unset($cleaned_request_data['CCDetails']['acct']);
366
+		unset($cleaned_request_data['CCDetails']['cvv2']);
367
+		unset($cleaned_request_data['CCDetails']['expdate']);
368
+		$this->log(array('Paypal Request' => $cleaned_request_data), $payment);
369
+	}
370
+
371
+
372
+
373
+	/**
374
+	 * Cleans the response, logs it, and returns it
375
+	 *
376
+	 * @param array       $response
377
+	 * @param EEI_Payment $payment
378
+	 * @return array cleaned
379
+	 */
380
+	private function _log_clean_response($response, $payment)
381
+	{
382
+		unset($response['REQUESTDATA']['CREDITCARDTYPE']);
383
+		unset($response['REQUESTDATA']['ACCT']);
384
+		unset($response['REQUESTDATA']['EXPDATE']);
385
+		unset($response['REQUESTDATA']['CVV2']);
386
+		unset($response['RAWREQUEST']);
387
+		$this->log(array('Paypal Response' => $response), $payment);
388
+		return $response;
389
+	}
390
+
391
+
392
+
393
+	/**
394
+	 * @param $DataArray
395
+	 * @return array
396
+	 */
397
+	private function prep_and_curl_request($DataArray)
398
+	{
399
+		// Create empty holders for each portion of the NVP string
400
+		$DPFieldsNVP = '&METHOD=DoDirectPayment&BUTTONSOURCE=AngellEYE_PHP_Class_DDP';
401
+		$CCDetailsNVP = '';
402
+		$PayerInfoNVP = '';
403
+		$PayerNameNVP = '';
404
+		$BillingAddressNVP = '';
405
+		$ShippingAddressNVP = '';
406
+		$PaymentDetailsNVP = '';
407
+		$OrderItemsNVP = '';
408
+		$Secure3DNVP = '';
409
+		// DP Fields
410
+		$DPFields = isset($DataArray['DPFields']) ? $DataArray['DPFields'] : array();
411
+		foreach ($DPFields as $DPFieldsVar => $DPFieldsVal) {
412
+			$DPFieldsNVP .= '&' . strtoupper($DPFieldsVar) . '=' . urlencode($DPFieldsVal);
413
+		}
414
+		// CC Details Fields
415
+		$CCDetails = isset($DataArray['CCDetails']) ? $DataArray['CCDetails'] : array();
416
+		foreach ($CCDetails as $CCDetailsVar => $CCDetailsVal) {
417
+			$CCDetailsNVP .= '&' . strtoupper($CCDetailsVar) . '=' . urlencode($CCDetailsVal);
418
+		}
419
+		// PayerInfo Type Fields
420
+		$PayerInfo = isset($DataArray['PayerInfo']) ? $DataArray['PayerInfo'] : array();
421
+		foreach ($PayerInfo as $PayerInfoVar => $PayerInfoVal) {
422
+			$PayerInfoNVP .= '&' . strtoupper($PayerInfoVar) . '=' . urlencode($PayerInfoVal);
423
+		}
424
+		// Payer Name Fields
425
+		$PayerName = isset($DataArray['PayerName']) ? $DataArray['PayerName'] : array();
426
+		foreach ($PayerName as $PayerNameVar => $PayerNameVal) {
427
+			$PayerNameNVP .= '&' . strtoupper($PayerNameVar) . '=' . urlencode($PayerNameVal);
428
+		}
429
+		// Address Fields (Billing)
430
+		$BillingAddress = isset($DataArray['BillingAddress']) ? $DataArray['BillingAddress'] : array();
431
+		foreach ($BillingAddress as $BillingAddressVar => $BillingAddressVal) {
432
+			$BillingAddressNVP .= '&' . strtoupper($BillingAddressVar) . '=' . urlencode($BillingAddressVal);
433
+		}
434
+		// Payment Details Type Fields
435
+		$PaymentDetails = isset($DataArray['PaymentDetails']) ? $DataArray['PaymentDetails'] : array();
436
+		foreach ($PaymentDetails as $PaymentDetailsVar => $PaymentDetailsVal) {
437
+			$PaymentDetailsNVP .= '&' . strtoupper($PaymentDetailsVar) . '=' . urlencode($PaymentDetailsVal);
438
+		}
439
+		// Payment Details Item Type Fields
440
+		$OrderItems = isset($DataArray['OrderItems']) ? $DataArray['OrderItems'] : array();
441
+		$n = 0;
442
+		foreach ($OrderItems as $OrderItemsVar => $OrderItemsVal) {
443
+			$CurrentItem = $OrderItems[$OrderItemsVar];
444
+			foreach ($CurrentItem as $CurrentItemVar => $CurrentItemVal) {
445
+				$OrderItemsNVP .= '&' . strtoupper($CurrentItemVar) . $n . '=' . urlencode($CurrentItemVal);
446
+			}
447
+			$n++;
448
+		}
449
+		// Ship To Address Fields
450
+		$ShippingAddress = isset($DataArray['ShippingAddress']) ? $DataArray['ShippingAddress'] : array();
451
+		foreach ($ShippingAddress as $ShippingAddressVar => $ShippingAddressVal) {
452
+			$ShippingAddressNVP .= '&' . strtoupper($ShippingAddressVar) . '=' . urlencode($ShippingAddressVal);
453
+		}
454
+		// 3D Secure Fields
455
+		$Secure3D = isset($DataArray['Secure3D']) ? $DataArray['Secure3D'] : array();
456
+		foreach ($Secure3D as $Secure3DVar => $Secure3DVal) {
457
+			$Secure3DNVP .= '&' . strtoupper($Secure3DVar) . '=' . urlencode($Secure3DVal);
458
+		}
459
+		// Now that we have each chunk we need to go ahead and append them all together for our entire NVP string
460
+		$NVPRequest = 'USER='
461
+					  . $this->_username
462
+					  . '&PWD='
463
+					  . $this->_password
464
+					  . '&VERSION=64.0'
465
+					  . '&SIGNATURE='
466
+					  . $this->_signature
467
+					  . $DPFieldsNVP
468
+					  . $CCDetailsNVP
469
+					  . $PayerInfoNVP
470
+					  . $PayerNameNVP
471
+					  . $BillingAddressNVP
472
+					  . $PaymentDetailsNVP
473
+					  . $OrderItemsNVP
474
+					  . $ShippingAddressNVP
475
+					  . $Secure3DNVP;
476
+		$NVPResponse = $this->_CURLRequest($NVPRequest);
477
+		$NVPRequestArray = $this->_NVPToArray($NVPRequest);
478
+		$NVPResponseArray = $this->_NVPToArray($NVPResponse);
479
+		$Errors = $this->_GetErrors($NVPResponseArray);
480
+		$NVPResponseArray['ERRORS'] = $Errors;
481
+		$NVPResponseArray['REQUESTDATA'] = $NVPRequestArray;
482
+		$NVPResponseArray['RAWREQUEST'] = $NVPRequest;
483
+		$NVPResponseArray['RAWRESPONSE'] = $NVPResponse;
484
+		return $NVPResponseArray;
485
+	}
486
+
487
+
488
+
489
+	/**
490
+	 * @param $Request
491
+	 * @return mixed
492
+	 */
493
+	private function _CURLRequest($Request)
494
+	{
495
+		$EndPointURL = $this->_debug_mode ? 'https://api-3t.sandbox.paypal.com/nvp' : 'https://api-3t.paypal.com/nvp';
496
+		$curl = curl_init();
497
+		curl_setopt($curl, CURLOPT_VERBOSE, apply_filters('FHEE__EEG_Paypal_Pro__CurlRequest__CURLOPT_VERBOSE', true));
498
+		curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
499
+		curl_setopt($curl, CURLOPT_TIMEOUT, 60);
500
+		curl_setopt($curl, CURLOPT_URL, $EndPointURL);
501
+		curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
502
+		curl_setopt($curl, CURLOPT_POSTFIELDS, $Request);
503
+		curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
504
+		//execute the curl POST
505
+		$Response = curl_exec($curl);
506
+		curl_close($curl);
507
+		return $Response;
508
+	}
509
+
510
+
511
+
512
+	/**
513
+	 * @param $NVPString
514
+	 * @return array
515
+	 */
516
+	private function _NVPToArray($NVPString)
517
+	{
518
+		// prepare responses into array
519
+		$proArray = array();
520
+		while (strlen($NVPString)) {
521
+			// name
522
+			$keypos = strpos($NVPString, '=');
523
+			$keyval = substr($NVPString, 0, $keypos);
524
+			// value
525
+			$valuepos = strpos($NVPString, '&') ? strpos($NVPString, '&') : strlen($NVPString);
526
+			$valval = substr($NVPString, $keypos + 1, $valuepos - $keypos - 1);
527
+			// decoding the response
528
+			$proArray[$keyval] = urldecode($valval);
529
+			$NVPString = substr($NVPString, $valuepos + 1, strlen($NVPString));
530
+		}
531
+		return $proArray;
532
+	}
533
+
534
+
535
+
536
+	/**
537
+	 * @param array $PayPalResult
538
+	 * @return bool
539
+	 */
540
+	private function _APICallSuccessful($PayPalResult)
541
+	{
542
+		$approved = false;
543
+		// check main response message from PayPal
544
+		if (isset($PayPalResult['ACK']) && ! empty($PayPalResult['ACK'])) {
545
+			$ack = strtoupper($PayPalResult['ACK']);
546
+			$approved = ($ack == 'SUCCESS' || $ack == 'SUCCESSWITHWARNING' || $ack == 'PARTIALSUCCESS') ? true : false;
547
+		}
548
+		return $approved;
549
+	}
550
+
551
+
552
+
553
+	/**
554
+	 * @param $DataArray
555
+	 * @return array
556
+	 */
557
+	private function _GetErrors($DataArray)
558
+	{
559
+		$Errors = array();
560
+		$n = 0;
561
+		while (isset($DataArray['L_ERRORCODE' . $n . ''])) {
562
+			$LErrorCode = isset($DataArray['L_ERRORCODE' . $n . '']) ? $DataArray['L_ERRORCODE' . $n . ''] : '';
563
+			$LShortMessage = isset($DataArray['L_SHORTMESSAGE' . $n . ''])
564
+				? $DataArray['L_SHORTMESSAGE' . $n . '']
565
+				: '';
566
+			$LLongMessage = isset($DataArray['L_LONGMESSAGE' . $n . ''])
567
+				? $DataArray['L_LONGMESSAGE' . $n . '']
568
+				: '';
569
+			$LSeverityCode = isset($DataArray['L_SEVERITYCODE' . $n . ''])
570
+				? $DataArray['L_SEVERITYCODE' . $n . '']
571
+				: '';
572
+			$CurrentItem = array(
573
+				'L_ERRORCODE'    => $LErrorCode,
574
+				'L_SHORTMESSAGE' => $LShortMessage,
575
+				'L_LONGMESSAGE'  => $LLongMessage,
576
+				'L_SEVERITYCODE' => $LSeverityCode,
577
+			);
578
+			array_push($Errors, $CurrentItem);
579
+			$n++;
580
+		}
581
+		return $Errors;
582
+	}
583
+
584
+
585
+
586
+	/**
587
+	 *        nothing to see here...  move along....
588
+	 *
589
+	 * @access protected
590
+	 * @param $Errors
591
+	 * @return string
592
+	 */
593
+	private function _DisplayErrors($Errors)
594
+	{
595
+		$error = '';
596
+		foreach ($Errors as $ErrorVar => $ErrorVal) {
597
+			$CurrentError = $Errors[$ErrorVar];
598
+			foreach ($CurrentError as $CurrentErrorVar => $CurrentErrorVal) {
599
+				$CurrentVarName = '';
600
+				if ($CurrentErrorVar == 'L_ERRORCODE') {
601
+					$CurrentVarName = 'Error Code';
602
+				} elseif ($CurrentErrorVar == 'L_SHORTMESSAGE') {
603
+					$CurrentVarName = 'Short Message';
604
+				} elseif ($CurrentErrorVar == 'L_LONGMESSAGE') {
605
+					$CurrentVarName = 'Long Message';
606
+				} elseif ($CurrentErrorVar == 'L_SEVERITYCODE') {
607
+					$CurrentVarName = 'Severity Code';
608
+				}
609
+				$error .= '<br />' . $CurrentVarName . ': ' . $CurrentErrorVal;
610
+			}
611
+		}
612
+		return $error;
613
+	}
614 614
 }
615 615
 // End of file EEG_Paypal_Pro.gateway.php
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (! defined('EVENT_ESPRESSO_VERSION')) {
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3 3
     exit('No direct script access allowed');
4 4
 }
5 5
 
@@ -91,13 +91,13 @@  discard block
 block discarded – undo
91 91
     public function do_direct_payment($payment, $billing_info = null)
92 92
     {
93 93
         $transaction = $payment->transaction();
94
-        if (! $transaction instanceof EEI_Transaction) {
94
+        if ( ! $transaction instanceof EEI_Transaction) {
95 95
             throw new EE_Error(
96 96
                 esc_html__('No transaction for payment while paying with PayPal Pro.', 'event_espresso')
97 97
             );
98 98
         }
99 99
         $primary_registrant = $transaction->primary_registration();
100
-        if (! $primary_registrant instanceof EEI_Registration) {
100
+        if ( ! $primary_registrant instanceof EEI_Registration) {
101 101
             throw new EE_Error(
102 102
                 esc_html__(
103 103
                     'No primary registration on transaction while paying with PayPal Pro.',
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
             );
107 107
         }
108 108
         $attendee = $primary_registrant->attendee();
109
-        if (! $attendee instanceof EEI_Attendee) {
109
+        if ( ! $attendee instanceof EEI_Attendee) {
110 110
             throw new EE_Error(
111 111
                 esc_html__(
112 112
                     'No attendee on primary registration while paying with PayPal Pro.',
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
             // Required.  Credit card number.  No spaces or punctuation.
203 203
             'acct'           => $billing_info['credit_card'],
204 204
             // Required.  Credit card expiration date.  Format is MMYYYY
205
-            'expdate'        => $billing_info['exp_month'] . $billing_info['exp_year'],
205
+            'expdate'        => $billing_info['exp_month'].$billing_info['exp_year'],
206 206
             // Requirements determined by your PayPal account settings.  Security digits for credit card.
207 207
             'cvv2'           => $billing_info['cvv'],
208 208
         );
@@ -254,7 +254,7 @@  discard block
 block discarded – undo
254 254
         $ShippingAddress = array(
255 255
             'shiptoname'     => substr($use_registration_address_info
256 256
                 ? $attendee->full_name()
257
-                : $billing_info['first_name'] . ' ' . $billing_info['last_name'], 0, 32),
257
+                : $billing_info['first_name'].' '.$billing_info['last_name'], 0, 32),
258 258
             'shiptostreet'   => substr($use_registration_address_info
259 259
                 ? $attendee->address()
260 260
                 : $billing_info['address'], 0, 100),
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
             'currencycode' => $payment->currency_code(),
284 284
             // Required if you include itemized cart details. (L_AMTn, etc.)
285 285
             //Subtotal of items not including S&H, or tax.
286
-            'itemamt'      => $this->format_currency($item_amount),//
286
+            'itemamt'      => $this->format_currency($item_amount), //
287 287
             // Total shipping costs for the order.  If you specify shippingamt, you must also specify itemamt.
288 288
             'shippingamt'  => '',
289 289
             // Total handling costs for the order.  If you specify handlingamt, you must also specify itemamt.
@@ -296,10 +296,10 @@  discard block
 block discarded – undo
296 296
             // Free-form field for your own use.  256 char max.
297 297
             'custom'       => $primary_registrant ? $primary_registrant->ID() : '',
298 298
             // Your own invoice or tracking number
299
-            'invnum'       => wp_generate_password(12, false),//$transaction->ID(),
299
+            'invnum'       => wp_generate_password(12, false), //$transaction->ID(),
300 300
             // URL for receiving Instant Payment Notifications.  This overrides what your profile is set to use.
301 301
             'notifyurl'    => '',
302
-            'buttonsource' => 'EventEspresso_SP',//EE will blow up if you change this
302
+            'buttonsource' => 'EventEspresso_SP', //EE will blow up if you change this
303 303
         );
304 304
         // Wrap all data arrays into a single, "master" array which will be passed into the class function.
305 305
         $PayPalRequestData = array(
@@ -409,32 +409,32 @@  discard block
 block discarded – undo
409 409
         // DP Fields
410 410
         $DPFields = isset($DataArray['DPFields']) ? $DataArray['DPFields'] : array();
411 411
         foreach ($DPFields as $DPFieldsVar => $DPFieldsVal) {
412
-            $DPFieldsNVP .= '&' . strtoupper($DPFieldsVar) . '=' . urlencode($DPFieldsVal);
412
+            $DPFieldsNVP .= '&'.strtoupper($DPFieldsVar).'='.urlencode($DPFieldsVal);
413 413
         }
414 414
         // CC Details Fields
415 415
         $CCDetails = isset($DataArray['CCDetails']) ? $DataArray['CCDetails'] : array();
416 416
         foreach ($CCDetails as $CCDetailsVar => $CCDetailsVal) {
417
-            $CCDetailsNVP .= '&' . strtoupper($CCDetailsVar) . '=' . urlencode($CCDetailsVal);
417
+            $CCDetailsNVP .= '&'.strtoupper($CCDetailsVar).'='.urlencode($CCDetailsVal);
418 418
         }
419 419
         // PayerInfo Type Fields
420 420
         $PayerInfo = isset($DataArray['PayerInfo']) ? $DataArray['PayerInfo'] : array();
421 421
         foreach ($PayerInfo as $PayerInfoVar => $PayerInfoVal) {
422
-            $PayerInfoNVP .= '&' . strtoupper($PayerInfoVar) . '=' . urlencode($PayerInfoVal);
422
+            $PayerInfoNVP .= '&'.strtoupper($PayerInfoVar).'='.urlencode($PayerInfoVal);
423 423
         }
424 424
         // Payer Name Fields
425 425
         $PayerName = isset($DataArray['PayerName']) ? $DataArray['PayerName'] : array();
426 426
         foreach ($PayerName as $PayerNameVar => $PayerNameVal) {
427
-            $PayerNameNVP .= '&' . strtoupper($PayerNameVar) . '=' . urlencode($PayerNameVal);
427
+            $PayerNameNVP .= '&'.strtoupper($PayerNameVar).'='.urlencode($PayerNameVal);
428 428
         }
429 429
         // Address Fields (Billing)
430 430
         $BillingAddress = isset($DataArray['BillingAddress']) ? $DataArray['BillingAddress'] : array();
431 431
         foreach ($BillingAddress as $BillingAddressVar => $BillingAddressVal) {
432
-            $BillingAddressNVP .= '&' . strtoupper($BillingAddressVar) . '=' . urlencode($BillingAddressVal);
432
+            $BillingAddressNVP .= '&'.strtoupper($BillingAddressVar).'='.urlencode($BillingAddressVal);
433 433
         }
434 434
         // Payment Details Type Fields
435 435
         $PaymentDetails = isset($DataArray['PaymentDetails']) ? $DataArray['PaymentDetails'] : array();
436 436
         foreach ($PaymentDetails as $PaymentDetailsVar => $PaymentDetailsVal) {
437
-            $PaymentDetailsNVP .= '&' . strtoupper($PaymentDetailsVar) . '=' . urlencode($PaymentDetailsVal);
437
+            $PaymentDetailsNVP .= '&'.strtoupper($PaymentDetailsVar).'='.urlencode($PaymentDetailsVal);
438 438
         }
439 439
         // Payment Details Item Type Fields
440 440
         $OrderItems = isset($DataArray['OrderItems']) ? $DataArray['OrderItems'] : array();
@@ -442,19 +442,19 @@  discard block
 block discarded – undo
442 442
         foreach ($OrderItems as $OrderItemsVar => $OrderItemsVal) {
443 443
             $CurrentItem = $OrderItems[$OrderItemsVar];
444 444
             foreach ($CurrentItem as $CurrentItemVar => $CurrentItemVal) {
445
-                $OrderItemsNVP .= '&' . strtoupper($CurrentItemVar) . $n . '=' . urlencode($CurrentItemVal);
445
+                $OrderItemsNVP .= '&'.strtoupper($CurrentItemVar).$n.'='.urlencode($CurrentItemVal);
446 446
             }
447 447
             $n++;
448 448
         }
449 449
         // Ship To Address Fields
450 450
         $ShippingAddress = isset($DataArray['ShippingAddress']) ? $DataArray['ShippingAddress'] : array();
451 451
         foreach ($ShippingAddress as $ShippingAddressVar => $ShippingAddressVal) {
452
-            $ShippingAddressNVP .= '&' . strtoupper($ShippingAddressVar) . '=' . urlencode($ShippingAddressVal);
452
+            $ShippingAddressNVP .= '&'.strtoupper($ShippingAddressVar).'='.urlencode($ShippingAddressVal);
453 453
         }
454 454
         // 3D Secure Fields
455 455
         $Secure3D = isset($DataArray['Secure3D']) ? $DataArray['Secure3D'] : array();
456 456
         foreach ($Secure3D as $Secure3DVar => $Secure3DVal) {
457
-            $Secure3DNVP .= '&' . strtoupper($Secure3DVar) . '=' . urlencode($Secure3DVal);
457
+            $Secure3DNVP .= '&'.strtoupper($Secure3DVar).'='.urlencode($Secure3DVal);
458 458
         }
459 459
         // Now that we have each chunk we need to go ahead and append them all together for our entire NVP string
460 460
         $NVPRequest = 'USER='
@@ -558,16 +558,16 @@  discard block
 block discarded – undo
558 558
     {
559 559
         $Errors = array();
560 560
         $n = 0;
561
-        while (isset($DataArray['L_ERRORCODE' . $n . ''])) {
562
-            $LErrorCode = isset($DataArray['L_ERRORCODE' . $n . '']) ? $DataArray['L_ERRORCODE' . $n . ''] : '';
563
-            $LShortMessage = isset($DataArray['L_SHORTMESSAGE' . $n . ''])
564
-                ? $DataArray['L_SHORTMESSAGE' . $n . '']
561
+        while (isset($DataArray['L_ERRORCODE'.$n.''])) {
562
+            $LErrorCode = isset($DataArray['L_ERRORCODE'.$n.'']) ? $DataArray['L_ERRORCODE'.$n.''] : '';
563
+            $LShortMessage = isset($DataArray['L_SHORTMESSAGE'.$n.''])
564
+                ? $DataArray['L_SHORTMESSAGE'.$n.'']
565 565
                 : '';
566
-            $LLongMessage = isset($DataArray['L_LONGMESSAGE' . $n . ''])
567
-                ? $DataArray['L_LONGMESSAGE' . $n . '']
566
+            $LLongMessage = isset($DataArray['L_LONGMESSAGE'.$n.''])
567
+                ? $DataArray['L_LONGMESSAGE'.$n.'']
568 568
                 : '';
569
-            $LSeverityCode = isset($DataArray['L_SEVERITYCODE' . $n . ''])
570
-                ? $DataArray['L_SEVERITYCODE' . $n . '']
569
+            $LSeverityCode = isset($DataArray['L_SEVERITYCODE'.$n.''])
570
+                ? $DataArray['L_SEVERITYCODE'.$n.'']
571 571
                 : '';
572 572
             $CurrentItem = array(
573 573
                 'L_ERRORCODE'    => $LErrorCode,
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
                 } elseif ($CurrentErrorVar == 'L_SEVERITYCODE') {
607 607
                     $CurrentVarName = 'Severity Code';
608 608
                 }
609
-                $error .= '<br />' . $CurrentVarName . ': ' . $CurrentErrorVal;
609
+                $error .= '<br />'.$CurrentVarName.': '.$CurrentErrorVal;
610 610
             }
611 611
         }
612 612
         return $error;
Please login to merge, or discard this patch.
payment_methods/Invoice/EE_PMT_Invoice.pm.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION'))
3
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
4 4
 	exit('No direct script access allowed');
5 5
 
6 6
 /**
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  *
26 26
  * ------------------------------------------------------------------------
27 27
  */
28
-class EE_PMT_Invoice extends EE_PMT_Base{
28
+class EE_PMT_Invoice extends EE_PMT_Base {
29 29
 
30 30
 
31 31
 
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	public function __construct($pm_instance = NULL) {
38 38
 		$this->_pretty_name = esc_html__("Invoice", 'event_espresso');
39 39
 		$this->_default_description = sprintf(
40
-			esc_html__( 'After clicking "Finalize Registration", you will be given instructions on how to access your invoice and complete your payment.%sPlease note that event spaces will not be reserved until payment is received in full, and any remaining tickets could be sold to others in the meantime.', 'event_espresso' ),
40
+			esc_html__('After clicking "Finalize Registration", you will be given instructions on how to access your invoice and complete your payment.%sPlease note that event spaces will not be reserved until payment is received in full, and any remaining tickets could be sold to others in the meantime.', 'event_espresso'),
41 41
 			'<br />'
42 42
 		);
43 43
 		parent::__construct($pm_instance);
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 	 * @param \EE_Transaction $transaction
52 52
 	 * @return NULL
53 53
 	 */
54
-	public function generate_new_billing_form( EE_Transaction $transaction = NULL ) {
54
+	public function generate_new_billing_form(EE_Transaction $transaction = NULL) {
55 55
 		return NULL;
56 56
 	}
57 57
 
@@ -64,53 +64,53 @@  discard block
 block discarded – undo
64 64
 	public function generate_new_settings_form() {
65 65
 		$pdf_payee_input_name = 'pdf_payee_name';
66 66
 		$confirmation_text_input_name = 'page_confirmation_text';
67
-		$form =  new EE_Payment_Method_Form(array(
67
+		$form = new EE_Payment_Method_Form(array(
68 68
 //				'payment_method_type' => $this,
69 69
 				'extra_meta_inputs'=>array(
70 70
 					$pdf_payee_input_name => new EE_Text_Input(array(
71
-						'html_label_text' => sprintf( esc_html__( 'Payee Name %s', 'event_espresso' ), $this->get_help_tab_link())
71
+						'html_label_text' => sprintf(esc_html__('Payee Name %s', 'event_espresso'), $this->get_help_tab_link())
72 72
 					)),
73 73
 					'pdf_payee_email' => new EE_Email_Input(array(
74
-						'html_label_text' => sprintf( esc_html__( 'Payee Email %s', 'event_espresso' ), $this->get_help_tab_link()),
74
+						'html_label_text' => sprintf(esc_html__('Payee Email %s', 'event_espresso'), $this->get_help_tab_link()),
75 75
 					)),
76 76
 					'pdf_payee_tax_number' => new EE_Text_Input(array(
77
-						'html_label_text' => sprintf( esc_html__( 'Payee Tax Number %s', 'event_espresso' ), $this->get_help_tab_link()),
77
+						'html_label_text' => sprintf(esc_html__('Payee Tax Number %s', 'event_espresso'), $this->get_help_tab_link()),
78 78
 						)),
79
-					'pdf_payee_address' => new EE_Text_Area_Input( array(
80
-						'html_label_text' => sprintf( esc_html__( 'Payee Address %s', 'event_espresso' ), $this->get_help_tab_link() ),
81
-						'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
79
+					'pdf_payee_address' => new EE_Text_Area_Input(array(
80
+						'html_label_text' => sprintf(esc_html__('Payee Address %s', 'event_espresso'), $this->get_help_tab_link()),
81
+						'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()),
82 82
 					)),
83 83
 					'pdf_instructions'=>new EE_Text_Area_Input(array(
84
-						'html_label_text'=>  sprintf(esc_html__("Instructions %s", "event_espresso"),  $this->get_help_tab_link()),
84
+						'html_label_text'=>  sprintf(esc_html__("Instructions %s", "event_espresso"), $this->get_help_tab_link()),
85 85
 						'default'=>  esc_html__("Please send this invoice with payment attached to the address above, or use the payment link below. Payment must be received within 48 hours of event date.", 'event_espresso'),
86
-						'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
86
+						'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()),
87 87
 					)),
88 88
 					'pdf_logo_image'=>new EE_Admin_File_Uploader_Input(array(
89
-						'html_label_text'=>  sprintf(esc_html__("Logo Image %s", "event_espresso"),  $this->get_help_tab_link()),
89
+						'html_label_text'=>  sprintf(esc_html__("Logo Image %s", "event_espresso"), $this->get_help_tab_link()),
90 90
 						'default'=>  EE_Config::instance()->organization->logo_url,
91 91
 						'html_help_text'=>  esc_html__("(Logo for the top left of the invoice)", 'event_espresso'),
92 92
 					)),
93 93
 					$confirmation_text_input_name =>new EE_Text_Area_Input(array(
94
-						'html_label_text'=>  sprintf(esc_html__("Confirmation Text %s", "event_espresso"),  $this->get_help_tab_link()),
94
+						'html_label_text'=>  sprintf(esc_html__("Confirmation Text %s", "event_espresso"), $this->get_help_tab_link()),
95 95
 						'default'=>  esc_html__("Payment must be received within 48 hours of event date. Details about where to send the payment are included on the invoice.", 'event_espresso'), 
96
-						'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
96
+						'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()),
97 97
 					)),
98 98
 					'page_extra_info'=>new EE_Text_Area_Input(array(
99
-						'html_label_text'=>  sprintf(esc_html__("Extra Info %s", "event_espresso"),  $this->get_help_tab_link()),
100
-						'validation_strategies' => array( new EE_Full_HTML_Validation_Strategy() ),
99
+						'html_label_text'=>  sprintf(esc_html__("Extra Info %s", "event_espresso"), $this->get_help_tab_link()),
100
+						'validation_strategies' => array(new EE_Full_HTML_Validation_Strategy()),
101 101
 					)),
102 102
 				),
103 103
 				'include'=>array(
104
-					'PMD_ID', 'PMD_name','PMD_desc','PMD_admin_name','PMD_admin_desc', 'PMD_type','PMD_slug', 'PMD_open_by_default','PMD_button_url','PMD_scope','Currency','PMD_order',
105
-					$pdf_payee_input_name, 'pdf_payee_email', 'pdf_payee_tax_number', 'pdf_payee_address', 'pdf_instructions','pdf_logo_image',
104
+					'PMD_ID', 'PMD_name', 'PMD_desc', 'PMD_admin_name', 'PMD_admin_desc', 'PMD_type', 'PMD_slug', 'PMD_open_by_default', 'PMD_button_url', 'PMD_scope', 'Currency', 'PMD_order',
105
+					$pdf_payee_input_name, 'pdf_payee_email', 'pdf_payee_tax_number', 'pdf_payee_address', 'pdf_instructions', 'pdf_logo_image',
106 106
 					$confirmation_text_input_name, 'page_extra_info'),
107 107
 			));
108 108
 		$form->add_subsections(
109
-			array( 'header1' => new EE_Form_Section_HTML_From_Template( 'payment_methods/Invoice/templates/invoice_settings_header_display.template.php' )),
109
+			array('header1' => new EE_Form_Section_HTML_From_Template('payment_methods/Invoice/templates/invoice_settings_header_display.template.php')),
110 110
 			$pdf_payee_input_name
111 111
 		);
112 112
 		$form->add_subsections(
113
-			array( 'header2'=>new EE_Form_Section_HTML_From_Template( 'payment_methods/Invoice/templates/invoice_settings_header_gateway.template.php' )),
113
+			array('header2'=>new EE_Form_Section_HTML_From_Template('payment_methods/Invoice/templates/invoice_settings_header_gateway.template.php')),
114 114
 			$confirmation_text_input_name
115 115
 		);
116 116
 		return $form;
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
 	 * @see EE_PMT_Base::help_tabs_config()
124 124
 	 * @return array
125 125
 	 */
126
-	public function help_tabs_config(){
126
+	public function help_tabs_config() {
127 127
 		return array(
128 128
 			$this->get_help_tab_name() => array(
129 129
 				'title' => esc_html__('Invoice Settings', 'event_espresso'),
@@ -141,16 +141,16 @@  discard block
 block discarded – undo
141 141
 	 * @param \EE_Payment $payment
142 142
 	 * @return string
143 143
 	 */
144
-	public function payment_overview_content( EE_Payment $payment ){
144
+	public function payment_overview_content(EE_Payment $payment) {
145 145
 		return EEH_Template::locate_template(
146
-			'payment_methods' . DS . 'Invoice'. DS . 'templates'.DS.'invoice_payment_details_content.template.php',
146
+			'payment_methods'.DS.'Invoice'.DS.'templates'.DS.'invoice_payment_details_content.template.php',
147 147
 			array_merge(
148 148
 				array(
149 149
 					'payment_method'			=> $this->_pm_instance,
150 150
 					'payment'						=> $payment,
151 151
 					'page_confirmation_text'					=> '',
152 152
 					'page_extra_info'	=> '',
153
-					'invoice_url' 					=> $payment->transaction()->primary_registration()->invoice_url( 'html' )
153
+					'invoice_url' 					=> $payment->transaction()->primary_registration()->invoice_url('html')
154 154
 				),
155 155
 				$this->_pm_instance->all_extra_meta_array()
156 156
 			)
Please login to merge, or discard this patch.
acceptance_tests/Helpers/EventsAdmin.php 1 patch
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -14,51 +14,51 @@
 block discarded – undo
14 14
 trait EventsAdmin
15 15
 {
16 16
 
17
-    /**
18
-     * @param string $additional_params
19
-     */
20
-    public function amOnDefaultEventsListTablePage($additional_params = '')
21
-    {
22
-        $this->actor()->amOnAdminPage(EventsPage::defaultEventsListTableUrl($additional_params));
23
-    }
17
+	/**
18
+	 * @param string $additional_params
19
+	 */
20
+	public function amOnDefaultEventsListTablePage($additional_params = '')
21
+	{
22
+		$this->actor()->amOnAdminPage(EventsPage::defaultEventsListTableUrl($additional_params));
23
+	}
24 24
 
25 25
 
26
-    /**
27
-     * Triggers the publishing of the Event.
28
-     */
29
-    public function publishEvent()
30
-    {
31
-        $this->actor()->click(EventsPage::EVENT_EDITOR_PUBLISH_BUTTON_SELECTOR);
32
-    }
26
+	/**
27
+	 * Triggers the publishing of the Event.
28
+	 */
29
+	public function publishEvent()
30
+	{
31
+		$this->actor()->click(EventsPage::EVENT_EDITOR_PUBLISH_BUTTON_SELECTOR);
32
+	}
33 33
 
34 34
 
35
-    /**
36
-     * Navigates the actor to the event list table page and will attempt to edit the event for the given title.
37
-     * First this will search using the given title and then attempt to edit from the results of the search.
38
-     *
39
-     * Assumes actor is already logged in.
40
-     * @param $event_title
41
-     */
42
-    public function amEditingTheEventWithTitle($event_title)
43
-    {
44
-        $this->amOnDefaultEventsListTablePage();
45
-        $this->actor()->fillField(EventsPage::EVENT_LIST_TABLE_SEARCH_INPUT_SELECTOR, $event_title);
46
-        $this->actor()->click(CoreAdmin::LIST_TABLE_SEARCH_SUBMIT_SELECTOR);
47
-        $this->actor()->waitForText('Displaying search results for');
48
-        $this->actor()->click(EventsPage::eventListTableEventTitleEditLink($event_title));
49
-    }
35
+	/**
36
+	 * Navigates the actor to the event list table page and will attempt to edit the event for the given title.
37
+	 * First this will search using the given title and then attempt to edit from the results of the search.
38
+	 *
39
+	 * Assumes actor is already logged in.
40
+	 * @param $event_title
41
+	 */
42
+	public function amEditingTheEventWithTitle($event_title)
43
+	{
44
+		$this->amOnDefaultEventsListTablePage();
45
+		$this->actor()->fillField(EventsPage::EVENT_LIST_TABLE_SEARCH_INPUT_SELECTOR, $event_title);
46
+		$this->actor()->click(CoreAdmin::LIST_TABLE_SEARCH_SUBMIT_SELECTOR);
47
+		$this->actor()->waitForText('Displaying search results for');
48
+		$this->actor()->click(EventsPage::eventListTableEventTitleEditLink($event_title));
49
+	}
50 50
 
51 51
 
52
-    /**
53
-     * Navigates the user to the single event page (frontend view) for the given event title via clicking the "View" link
54
-     * for the event in the event list table.
55
-     *
56
-     * Assumes the actor is already logged in and on the Event list table page.
57
-     * @param string $event_title
58
-     */
59
-    public function amOnEventPageAfterClickingViewLinkInListTableForEvent($event_title)
60
-    {
61
-        $this->actor()->moveMouseOver(EventsPage::eventListTableEventTitleEditLinkSelectorForTitle($event_title));
62
-        $this->actor()->click(EventsPage::eventListTableEventTitleViewLinkSelectorForTitle($event_title));
63
-    }
52
+	/**
53
+	 * Navigates the user to the single event page (frontend view) for the given event title via clicking the "View" link
54
+	 * for the event in the event list table.
55
+	 *
56
+	 * Assumes the actor is already logged in and on the Event list table page.
57
+	 * @param string $event_title
58
+	 */
59
+	public function amOnEventPageAfterClickingViewLinkInListTableForEvent($event_title)
60
+	{
61
+		$this->actor()->moveMouseOver(EventsPage::eventListTableEventTitleEditLinkSelectorForTitle($event_title));
62
+		$this->actor()->click(EventsPage::eventListTableEventTitleViewLinkSelectorForTitle($event_title));
63
+	}
64 64
 }
65 65
\ No newline at end of file
Please login to merge, or discard this patch.
acceptance_tests/Helpers/MessagesAdmin.php 1 patch
Indentation   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -10,96 +10,96 @@
 block discarded – undo
10 10
  */
11 11
 trait MessagesAdmin
12 12
 {
13
-    /**
14
-     * @param string $additional_params Any additional request parameters for the generated url should be included as
15
-     *                                  a string.
16
-     */
17
-    public function amOnMessagesActivityListTablePage($additional_params = '')
18
-    {
19
-        $this->actor()->amOnAdminPage(MessagesPage::messageActivityListTableUrl($additional_params));
20
-    }
13
+	/**
14
+	 * @param string $additional_params Any additional request parameters for the generated url should be included as
15
+	 *                                  a string.
16
+	 */
17
+	public function amOnMessagesActivityListTablePage($additional_params = '')
18
+	{
19
+		$this->actor()->amOnAdminPage(MessagesPage::messageActivityListTableUrl($additional_params));
20
+	}
21 21
 
22
-    /**
23
-     * @param string $additional_params Any additional request parameters for the generated url should be included as
24
-     *                                  a string.
25
-     */
26
-    public function amOnDefaultMessageTemplateListTablePage($additional_params = '')
27
-    {
28
-        $this->actor()->amOnAdminPage(MessagesPage::defaultMessageTemplateListTableUrl($additional_params));
29
-    }
22
+	/**
23
+	 * @param string $additional_params Any additional request parameters for the generated url should be included as
24
+	 *                                  a string.
25
+	 */
26
+	public function amOnDefaultMessageTemplateListTablePage($additional_params = '')
27
+	{
28
+		$this->actor()->amOnAdminPage(MessagesPage::defaultMessageTemplateListTableUrl($additional_params));
29
+	}
30 30
 
31 31
 
32
-    /**
33
-     * @param string $additional_params Any additional request parameters for the generated url should be included as
34
-     *                                  a string.
35
-     */
36
-    public function amOnCustomMessageTemplateListTablePage($additional_params = '')
37
-    {
38
-        $this->actor()->amOnAdminPage(MessagesPage::customMessageTemplateListTableUrl($additional_params));
39
-    }
32
+	/**
33
+	 * @param string $additional_params Any additional request parameters for the generated url should be included as
34
+	 *                                  a string.
35
+	 */
36
+	public function amOnCustomMessageTemplateListTablePage($additional_params = '')
37
+	{
38
+		$this->actor()->amOnAdminPage(MessagesPage::customMessageTemplateListTableUrl($additional_params));
39
+	}
40 40
 
41 41
 
42
-    /**
43
-     * Directs to message settings page
44
-     */
45
-    public function amOnMessageSettingsPage()
46
-    {
47
-        $this->actor()->amOnAdminPage(MessagesPage::messageSettingsUrl());
48
-    }
42
+	/**
43
+	 * Directs to message settings page
44
+	 */
45
+	public function amOnMessageSettingsPage()
46
+	{
47
+		$this->actor()->amOnAdminPage(MessagesPage::messageSettingsUrl());
48
+	}
49 49
 
50 50
 
51
-    /**
52
-     * Assumes you are already on the list table page that has the ui for editing the template.
53
-     * @param string $message_type_slug
54
-     * @param string $context [optional] if you want to click directly to the given context in the editor
55
-     */
56
-    public function clickToEditMessageTemplateByMessageType($message_type_slug, $context = '')
57
-    {
58
-        $this->actor()->click(MessagesPage::editMessageTemplateClassByMessageType($message_type_slug, $context));
59
-    }
51
+	/**
52
+	 * Assumes you are already on the list table page that has the ui for editing the template.
53
+	 * @param string $message_type_slug
54
+	 * @param string $context [optional] if you want to click directly to the given context in the editor
55
+	 */
56
+	public function clickToEditMessageTemplateByMessageType($message_type_slug, $context = '')
57
+	{
58
+		$this->actor()->click(MessagesPage::editMessageTemplateClassByMessageType($message_type_slug, $context));
59
+	}
60 60
 
61 61
 
62
-    /**
63
-     * Use this action to verify that the count for the given text in the specified field is as expected.  For example
64
-     * filling the condition of, "There should only be 1 instance of `[email protected]` in all the 'to' column.
65
-     *
66
-     * @param int    $expected_occurence_count
67
-     * @param string $text_to_check_for
68
-     * @param string $field
69
-     * @param string $message_type_label
70
-     * @param string $message_status
71
-     * @param string $messenger
72
-     * @param string $context
73
-     */
74
-    public function verifyMatchingCountofTextInMessageActivityListTableFor(
75
-        $expected_occurence_count,
76
-        $text_to_check_for,
77
-        $field,
78
-        $message_type_label,
79
-        $message_status = MessagesPage::MESSAGE_STATUS_SENT,
80
-        $messenger = 'Email',
81
-        $context = 'Event Admin'
82
-    ) {
83
-        $elements = $this->actor()->grabMultiple(MessagesPage::messagesActivityListTableCellSelectorFor(
84
-            $field,
85
-            $message_type_label,
86
-            $message_status,
87
-            $messenger,
88
-            $context,
89
-            $text_to_check_for
90
-        ));
91
-        $actual_count = count($elements);
92
-        $this->actor()->assertEquals(
93
-            $expected_occurence_count,
94
-            $actual_count,
95
-            sprintf(
96
-                'Expected %s of the %s text for the %s field but there were actually %s counted.',
97
-                $expected_occurence_count,
98
-                $text_to_check_for,
99
-                $field,
100
-                $actual_count
101
-            )
102
-        );
103
-    }
62
+	/**
63
+	 * Use this action to verify that the count for the given text in the specified field is as expected.  For example
64
+	 * filling the condition of, "There should only be 1 instance of `[email protected]` in all the 'to' column.
65
+	 *
66
+	 * @param int    $expected_occurence_count
67
+	 * @param string $text_to_check_for
68
+	 * @param string $field
69
+	 * @param string $message_type_label
70
+	 * @param string $message_status
71
+	 * @param string $messenger
72
+	 * @param string $context
73
+	 */
74
+	public function verifyMatchingCountofTextInMessageActivityListTableFor(
75
+		$expected_occurence_count,
76
+		$text_to_check_for,
77
+		$field,
78
+		$message_type_label,
79
+		$message_status = MessagesPage::MESSAGE_STATUS_SENT,
80
+		$messenger = 'Email',
81
+		$context = 'Event Admin'
82
+	) {
83
+		$elements = $this->actor()->grabMultiple(MessagesPage::messagesActivityListTableCellSelectorFor(
84
+			$field,
85
+			$message_type_label,
86
+			$message_status,
87
+			$messenger,
88
+			$context,
89
+			$text_to_check_for
90
+		));
91
+		$actual_count = count($elements);
92
+		$this->actor()->assertEquals(
93
+			$expected_occurence_count,
94
+			$actual_count,
95
+			sprintf(
96
+				'Expected %s of the %s text for the %s field but there were actually %s counted.',
97
+				$expected_occurence_count,
98
+				$text_to_check_for,
99
+				$field,
100
+				$actual_count
101
+			)
102
+		);
103
+	}
104 104
 
105 105
 }
106 106
\ No newline at end of file
Please login to merge, or discard this patch.
core/EE_Encryption.core.php 2 patches
Indentation   +501 added lines, -501 removed lines patch added patch discarded remove patch
@@ -16,507 +16,507 @@
 block discarded – undo
16 16
 class EE_Encryption
17 17
 {
18 18
 
19
-    /**
20
-     * key used for saving the encryption key to the wp_options table
21
-     */
22
-    const ENCRYPTION_OPTION_KEY = 'ee_encryption_key';
23
-
24
-    /**
25
-     * the OPENSSL cipher method used
26
-     */
27
-    const OPENSSL_CIPHER_METHOD = 'aes-256-ctr';
28
-
29
-    /**
30
-     * the OPENSSL digest method used
31
-     */
32
-    const OPENSSL_DIGEST_METHOD = 'sha512';
33
-
34
-    /**
35
-     * separates the encrypted text from the initialization vector
36
-     */
37
-    const OPENSSL_IV_DELIMITER = ':iv:';
38
-
39
-
40
-
41
-    /**
42
-     * instance of the EE_Encryption object
43
-     */
44
-    protected static $_instance;
45
-
46
-    /**
47
-     * @var string $_encryption_key
48
-     */
49
-    protected $_encryption_key;
50
-
51
-    /**
52
-     * @var boolean $_use_openssl_encrypt
53
-     */
54
-    protected $_use_openssl_encrypt = false;
55
-
56
-    /**
57
-     * @var boolean $_use_mcrypt
58
-     */
59
-    protected $_use_mcrypt = false;
60
-
61
-    /**
62
-     * @var boolean $_use_base64_encode
63
-     */
64
-    protected $_use_base64_encode = false;
65
-
66
-
67
-
68
-    /**
69
-     * protected constructor to prevent direct creation
70
-     */
71
-    protected function __construct()
72
-    {
73
-        if (! defined('ESPRESSO_ENCRYPT')) {
74
-            define('ESPRESSO_ENCRYPT', true);
75
-        }
76
-        if (extension_loaded('openssl')) {
77
-            $this->_use_openssl_encrypt = true;
78
-        } else if (extension_loaded('mcrypt')) {
79
-            $this->_use_mcrypt = true;
80
-        }
81
-        if (function_exists('base64_encode')) {
82
-            $this->_use_base64_encode = true;
83
-        }
84
-    }
85
-
86
-
87
-
88
-    /**
89
-     * singleton method used to instantiate class object
90
-     *
91
-     * @return EE_Encryption
92
-     */
93
-    public static function instance()
94
-    {
95
-        // check if class object is instantiated
96
-        if (! self::$_instance instanceof EE_Encryption) {
97
-            self::$_instance = new self();
98
-        }
99
-        return self::$_instance;
100
-    }
101
-
102
-
103
-
104
-    /**
105
-     * get encryption key
106
-     *
107
-     * @return string
108
-     */
109
-    public function get_encryption_key()
110
-    {
111
-        // if encryption key has not been set
112
-        if (empty($this->_encryption_key)) {
113
-            // retrieve encryption_key from db
114
-            $this->_encryption_key = get_option(EE_Encryption::ENCRYPTION_OPTION_KEY, '');
115
-            // WHAT?? No encryption_key in the db ??
116
-            if ($this->_encryption_key === '') {
117
-                // let's make one. And md5 it to make it just the right size for a key
118
-                $new_key = md5($this->generate_random_string());
119
-                // now save it to the db for later
120
-                add_option(EE_Encryption::ENCRYPTION_OPTION_KEY, $new_key);
121
-                // here's the key - FINALLY !
122
-                $this->_encryption_key = $new_key;
123
-            }
124
-        }
125
-        return $this->_encryption_key;
126
-    }
127
-
128
-
129
-
130
-    /**
131
-     * encrypts data
132
-     *
133
-     * @param string $text_string - the text to be encrypted
134
-     * @return string
135
-     * @throws RuntimeException
136
-     */
137
-    public function encrypt($text_string = '')
138
-    {
139
-        // you give me nothing??? GET OUT !
140
-        if (empty($text_string)) {
141
-            return $text_string;
142
-        }
143
-        if ($this->_use_openssl_encrypt) {
144
-            $encrypted_text = $this->openssl_encrypt($text_string);
145
-        } else {
146
-            $encrypted_text = $this->acme_encrypt($text_string);
147
-        }
148
-        return $encrypted_text;
149
-    }
150
-
151
-
152
-
153
-    /**
154
-     * decrypts data
155
-     *
156
-     * @param string $encrypted_text - the text to be decrypted
157
-     * @return string
158
-     * @throws RuntimeException
159
-     */
160
-    public function decrypt($encrypted_text = '')
161
-    {
162
-        // you give me nothing??? GET OUT !
163
-        if (empty($encrypted_text)) {
164
-            return $encrypted_text;
165
-        }
166
-        // if PHP's mcrypt functions are installed then we'll use them
167
-        if ($this->_use_openssl_encrypt) {
168
-            $decrypted_text = $this->openssl_decrypt($encrypted_text);
169
-        } else if ($this->_use_mcrypt) {
170
-            $decrypted_text = $this->m_decrypt($encrypted_text);
171
-        } else {
172
-            $decrypted_text = $this->acme_decrypt($encrypted_text);
173
-        }
174
-        return $decrypted_text;
175
-    }
176
-
177
-
178
-
179
-    /**
180
-     * encodes string with PHP's base64 encoding
181
-     *
182
-     * @see http://php.net/manual/en/function.base64-encode.php
183
-     * @param string $text_string the text to be encoded
184
-     * @return string
185
-     */
186
-    public function base64_string_encode($text_string = '')
187
-    {
188
-        // you give me nothing??? GET OUT !
189
-        if (empty($text_string) || ! $this->_use_base64_encode) {
190
-            return $text_string;
191
-        }
192
-        // encode
193
-        return base64_encode($text_string);
194
-    }
195
-
196
-
197
-
198
-    /**
199
-     * decodes string that has been encoded with PHP's base64 encoding
200
-     *
201
-     * @see http://php.net/manual/en/function.base64-encode.php
202
-     * @param string $encoded_string the text to be decoded
203
-     * @return string
204
-     */
205
-    public function base64_string_decode($encoded_string = '')
206
-    {
207
-        // you give me nothing??? GET OUT !
208
-        if (empty($encoded_string) || ! $this->valid_base_64($encoded_string)) {
209
-            return $encoded_string;
210
-        }
211
-        // decode
212
-        return base64_decode($encoded_string);
213
-    }
214
-
215
-
216
-
217
-    /**
218
-     * encodes  url string with PHP's base64 encoding
219
-     *
220
-     * @see http://php.net/manual/en/function.base64-encode.php
221
-     * @param string $text_string the text to be encoded
222
-     * @return string
223
-     */
224
-    public function base64_url_encode($text_string = '')
225
-    {
226
-        // you give me nothing??? GET OUT !
227
-        if (empty($text_string) || ! $this->_use_base64_encode) {
228
-            return $text_string;
229
-        }
230
-        // encode
231
-        $encoded_string = base64_encode($text_string);
232
-        // remove chars to make encoding more URL friendly
233
-        return strtr($encoded_string, '+/=', '-_,');
234
-    }
235
-
236
-
237
-
238
-    /**
239
-     * decodes  url string that has been encoded with PHP's base64 encoding
240
-     *
241
-     * @see http://php.net/manual/en/function.base64-encode.php
242
-     * @param string $encoded_string the text to be decoded
243
-     * @return string
244
-     */
245
-    public function base64_url_decode($encoded_string = '')
246
-    {
247
-        // you give me nothing??? GET OUT !
248
-        if (empty($encoded_string) || ! $this->valid_base_64($encoded_string)) {
249
-            return $encoded_string;
250
-        }
251
-        // replace previously removed characters
252
-        $encoded_string = strtr($encoded_string, '-_,', '+/=');
253
-        // decode
254
-        return base64_decode($encoded_string);
255
-    }
256
-
257
-
258
-
259
-    /**
260
-     * encrypts data using PHP's openssl functions
261
-     *
262
-     * @param string $text_string the text to be encrypted
263
-     * @return string
264
-     * @throws RuntimeException
265
-     */
266
-    protected function openssl_encrypt($text_string = '')
267
-    {
268
-        // you give me nothing??? GET OUT !
269
-        if (empty($text_string)) {
270
-            return $text_string;
271
-        }
272
-        // get initialization vector size
273
-        $iv_size = openssl_cipher_iv_length(EE_Encryption::OPENSSL_CIPHER_METHOD);
274
-        // generate initialization vector
275
-        $iv = openssl_random_pseudo_bytes($iv_size, $is_strong);
276
-        if ($iv === false || $is_strong === false) {
277
-            throw new RuntimeException(
278
-                esc_html__('Failed to generate OpenSSL initialization vector.', 'event_espresso')
279
-            );
280
-        }
281
-        // encrypt it
282
-        $encrypted_text = openssl_encrypt(
283
-            $text_string,
284
-            EE_Encryption::OPENSSL_CIPHER_METHOD,
285
-            openssl_digest($this->get_encryption_key(), EE_Encryption::OPENSSL_DIGEST_METHOD),
286
-            0,
287
-            $iv
288
-        );
289
-        // append the initialization vector
290
-        $encrypted_text .= EE_Encryption::OPENSSL_IV_DELIMITER . $iv;
291
-        // trim and maybe encode
292
-        return $this->_use_base64_encode
293
-            ? trim(base64_encode($encrypted_text))
294
-            : trim($encrypted_text);
295
-    }
296
-
297
-
298
-
299
-    /**
300
-     * decrypts data that has been encrypted with PHP's openssl functions
301
-     *
302
-     * @param string $encrypted_text the text to be decrypted
303
-     * @return string
304
-     * @throws RuntimeException
305
-     */
306
-    protected function openssl_decrypt($encrypted_text = '')
307
-    {
308
-        // you give me nothing??? GET OUT !
309
-        if (empty($encrypted_text)) {
310
-            return $encrypted_text;
311
-        }
312
-        // decode
313
-        $encrypted_text = $this->valid_base_64($encrypted_text)
314
-            ? base64_decode($encrypted_text)
315
-            : $encrypted_text;
316
-        $encrypted_components = explode(
317
-            EE_Encryption::OPENSSL_IV_DELIMITER,
318
-            $encrypted_text,
319
-            2
320
-        );
321
-        // check that iv exists, and if not, maybe text was encoded using mcrypt?
322
-        if (! isset($encrypted_components[1]) && $this->_use_mcrypt) {
323
-            return $this->m_decrypt($encrypted_text);
324
-        }
325
-        // decrypt it
326
-        $decrypted_text = openssl_decrypt(
327
-            $encrypted_components[0],
328
-            EE_Encryption::OPENSSL_CIPHER_METHOD,
329
-            openssl_digest($this->get_encryption_key(), EE_Encryption::OPENSSL_DIGEST_METHOD),
330
-            0,
331
-            $encrypted_components[1]
332
-        );
333
-        $decrypted_text = trim($decrypted_text);
334
-        return $decrypted_text;
335
-    }
336
-
337
-
338
-
339
-    /**
340
-     * encrypts data for acme servers that didn't bother to install PHP mcrypt
341
-     *
342
-     * @see http://stackoverflow.com/questions/800922/how-to-encrypt-string-without-mcrypt-library-in-php
343
-     * @param string $text_string the text to be decrypted
344
-     * @return string
345
-     */
346
-    protected function acme_encrypt($text_string = '')
347
-    {
348
-        // you give me nothing??? GET OUT !
349
-        if (empty($text_string)) {
350
-            return $text_string;
351
-        }
352
-        $key_bits = str_split(
353
-            str_pad('', strlen($text_string), $this->get_encryption_key(), STR_PAD_RIGHT)
354
-        );
355
-        $string_bits = str_split($text_string);
356
-        foreach ($string_bits as $k => $v) {
357
-            $temp = ord($v) + ord($key_bits[$k]);
358
-            $string_bits[$k] = chr($temp > 255 ? ($temp - 256) : $temp);
359
-        }
360
-        return $this->_use_base64_encode
361
-            ? base64_encode(implode('', $string_bits))
362
-            : implode('', $string_bits);
363
-    }
364
-
365
-
366
-
367
-    /**
368
-     * decrypts data for acme servers that didn't bother to install PHP mcrypt
369
-     *
370
-     * @see http://stackoverflow.com/questions/800922/how-to-encrypt-string-without-mcrypt-library-in-php
371
-     * @param string $encrypted_text the text to be decrypted
372
-     * @return string
373
-     */
374
-    protected function acme_decrypt($encrypted_text = '')
375
-    {
376
-        // you give me nothing??? GET OUT !
377
-        if (empty($encrypted_text)) {
378
-            return $encrypted_text;
379
-        }
380
-        // decode the data ?
381
-        $encrypted_text = $this->valid_base_64($encrypted_text)
382
-            ? base64_decode($encrypted_text)
383
-            : $encrypted_text;
384
-        $key_bits = str_split(
385
-            str_pad('', strlen($encrypted_text), $this->get_encryption_key(), STR_PAD_RIGHT)
386
-        );
387
-        $string_bits = str_split($encrypted_text);
388
-        foreach ($string_bits as $k => $v) {
389
-            $temp = ord($v) - ord($key_bits[$k]);
390
-            $string_bits[$k] = chr($temp < 0 ? ($temp + 256) : $temp);
391
-        }
392
-        return implode('', $string_bits);
393
-    }
394
-
395
-
396
-
397
-    /**
398
-     * @see http://stackoverflow.com/questions/2556345/detect-base64-encoding-in-php#30231906
399
-     * @param $string
400
-     * @return bool
401
-     */
402
-    protected function valid_base_64($string)
403
-    {
404
-        // ensure data is a string
405
-        if (! is_string($string) || ! $this->_use_base64_encode) {
406
-            return false;
407
-        }
408
-        $decoded = base64_decode($string, true);
409
-        // Check if there is no invalid character in string
410
-        if (! preg_match('/^[a-zA-Z0-9\/\r\n+]*={0,2}$/', $string)) {
411
-            return false;
412
-        }
413
-        // Decode the string in strict mode and send the response
414
-        if (! base64_decode($string, true)) {
415
-            return false;
416
-        }
417
-        // Encode and compare it to original one
418
-        return base64_encode($decoded) === $string;
419
-    }
420
-
421
-
422
-
423
-    /**
424
-     * generate random string
425
-     *
426
-     * @see http://stackoverflow.com/questions/637278/what-is-the-best-way-to-generate-a-random-key-within-php
427
-     * @param int $length number of characters for random string
428
-     * @return string
429
-     */
430
-    public function generate_random_string($length = 40)
431
-    {
432
-        $iterations = ceil($length / 40);
433
-        $random_string = '';
434
-        for ($i = 0; $i < $iterations; $i++) {
435
-            $random_string .= sha1(microtime(true) . mt_rand(10000, 90000));
436
-        }
437
-        $random_string = substr($random_string, 0, $length);
438
-        return $random_string;
439
-    }
440
-
441
-
442
-
443
-    /**
444
-     * encrypts data using PHP's mcrypt functions
445
-     *
446
-     * @deprecated 4.9.39
447
-     * @param string $text_string
448
-     * @internal   param $string - the text to be encrypted
449
-     * @return string
450
-     * @throws RuntimeException
451
-     */
452
-    protected function m_encrypt($text_string = '')
453
-    {
454
-        // you give me nothing??? GET OUT !
455
-        if (empty($text_string)) {
456
-            return $text_string;
457
-        }
458
-        // get the initialization vector size
459
-        $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
460
-        // initialization vector
461
-        $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
462
-        if ($iv === false) {
463
-            throw new RuntimeException(
464
-                esc_html__('Failed to generate mcrypt initialization vector.', 'event_espresso')
465
-            );
466
-        }
467
-        // encrypt it
468
-        $encrypted_text = mcrypt_encrypt(
469
-            MCRYPT_RIJNDAEL_256,
470
-            $this->get_encryption_key(),
471
-            $text_string,
472
-            MCRYPT_MODE_ECB,
473
-            $iv
474
-        );
475
-        // trim and maybe encode
476
-        return $this->_use_base64_encode
477
-            ? trim(base64_encode($encrypted_text))
478
-            : trim($encrypted_text);
479
-    }
480
-
481
-
482
-
483
-    /**
484
-     * decrypts data that has been encrypted with PHP's mcrypt functions
485
-     *
486
-     * @deprecated 4.9.39
487
-     * @param string $encrypted_text the text to be decrypted
488
-     * @return string
489
-     * @throws RuntimeException
490
-     */
491
-    protected function m_decrypt($encrypted_text = '')
492
-    {
493
-        // you give me nothing??? GET OUT !
494
-        if (empty($encrypted_text)) {
495
-            return $encrypted_text;
496
-        }
497
-        // decode
498
-        $encrypted_text = $this->valid_base_64($encrypted_text)
499
-            ? base64_decode($encrypted_text)
500
-            : $encrypted_text;
501
-        // get the initialization vector size
502
-        $iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
503
-        $iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
504
-        if ($iv === false) {
505
-            throw new RuntimeException(
506
-                esc_html__('Failed to generate mcrypt initialization vector.', 'event_espresso')
507
-            );
508
-        }
509
-        // decrypt it
510
-        $decrypted_text = mcrypt_decrypt(
511
-            MCRYPT_RIJNDAEL_256,
512
-            $this->get_encryption_key(),
513
-            $encrypted_text,
514
-            MCRYPT_MODE_ECB,
515
-            $iv
516
-        );
517
-        $decrypted_text = trim($decrypted_text);
518
-        return $decrypted_text;
519
-    }
19
+	/**
20
+	 * key used for saving the encryption key to the wp_options table
21
+	 */
22
+	const ENCRYPTION_OPTION_KEY = 'ee_encryption_key';
23
+
24
+	/**
25
+	 * the OPENSSL cipher method used
26
+	 */
27
+	const OPENSSL_CIPHER_METHOD = 'aes-256-ctr';
28
+
29
+	/**
30
+	 * the OPENSSL digest method used
31
+	 */
32
+	const OPENSSL_DIGEST_METHOD = 'sha512';
33
+
34
+	/**
35
+	 * separates the encrypted text from the initialization vector
36
+	 */
37
+	const OPENSSL_IV_DELIMITER = ':iv:';
38
+
39
+
40
+
41
+	/**
42
+	 * instance of the EE_Encryption object
43
+	 */
44
+	protected static $_instance;
45
+
46
+	/**
47
+	 * @var string $_encryption_key
48
+	 */
49
+	protected $_encryption_key;
50
+
51
+	/**
52
+	 * @var boolean $_use_openssl_encrypt
53
+	 */
54
+	protected $_use_openssl_encrypt = false;
55
+
56
+	/**
57
+	 * @var boolean $_use_mcrypt
58
+	 */
59
+	protected $_use_mcrypt = false;
60
+
61
+	/**
62
+	 * @var boolean $_use_base64_encode
63
+	 */
64
+	protected $_use_base64_encode = false;
65
+
66
+
67
+
68
+	/**
69
+	 * protected constructor to prevent direct creation
70
+	 */
71
+	protected function __construct()
72
+	{
73
+		if (! defined('ESPRESSO_ENCRYPT')) {
74
+			define('ESPRESSO_ENCRYPT', true);
75
+		}
76
+		if (extension_loaded('openssl')) {
77
+			$this->_use_openssl_encrypt = true;
78
+		} else if (extension_loaded('mcrypt')) {
79
+			$this->_use_mcrypt = true;
80
+		}
81
+		if (function_exists('base64_encode')) {
82
+			$this->_use_base64_encode = true;
83
+		}
84
+	}
85
+
86
+
87
+
88
+	/**
89
+	 * singleton method used to instantiate class object
90
+	 *
91
+	 * @return EE_Encryption
92
+	 */
93
+	public static function instance()
94
+	{
95
+		// check if class object is instantiated
96
+		if (! self::$_instance instanceof EE_Encryption) {
97
+			self::$_instance = new self();
98
+		}
99
+		return self::$_instance;
100
+	}
101
+
102
+
103
+
104
+	/**
105
+	 * get encryption key
106
+	 *
107
+	 * @return string
108
+	 */
109
+	public function get_encryption_key()
110
+	{
111
+		// if encryption key has not been set
112
+		if (empty($this->_encryption_key)) {
113
+			// retrieve encryption_key from db
114
+			$this->_encryption_key = get_option(EE_Encryption::ENCRYPTION_OPTION_KEY, '');
115
+			// WHAT?? No encryption_key in the db ??
116
+			if ($this->_encryption_key === '') {
117
+				// let's make one. And md5 it to make it just the right size for a key
118
+				$new_key = md5($this->generate_random_string());
119
+				// now save it to the db for later
120
+				add_option(EE_Encryption::ENCRYPTION_OPTION_KEY, $new_key);
121
+				// here's the key - FINALLY !
122
+				$this->_encryption_key = $new_key;
123
+			}
124
+		}
125
+		return $this->_encryption_key;
126
+	}
127
+
128
+
129
+
130
+	/**
131
+	 * encrypts data
132
+	 *
133
+	 * @param string $text_string - the text to be encrypted
134
+	 * @return string
135
+	 * @throws RuntimeException
136
+	 */
137
+	public function encrypt($text_string = '')
138
+	{
139
+		// you give me nothing??? GET OUT !
140
+		if (empty($text_string)) {
141
+			return $text_string;
142
+		}
143
+		if ($this->_use_openssl_encrypt) {
144
+			$encrypted_text = $this->openssl_encrypt($text_string);
145
+		} else {
146
+			$encrypted_text = $this->acme_encrypt($text_string);
147
+		}
148
+		return $encrypted_text;
149
+	}
150
+
151
+
152
+
153
+	/**
154
+	 * decrypts data
155
+	 *
156
+	 * @param string $encrypted_text - the text to be decrypted
157
+	 * @return string
158
+	 * @throws RuntimeException
159
+	 */
160
+	public function decrypt($encrypted_text = '')
161
+	{
162
+		// you give me nothing??? GET OUT !
163
+		if (empty($encrypted_text)) {
164
+			return $encrypted_text;
165
+		}
166
+		// if PHP's mcrypt functions are installed then we'll use them
167
+		if ($this->_use_openssl_encrypt) {
168
+			$decrypted_text = $this->openssl_decrypt($encrypted_text);
169
+		} else if ($this->_use_mcrypt) {
170
+			$decrypted_text = $this->m_decrypt($encrypted_text);
171
+		} else {
172
+			$decrypted_text = $this->acme_decrypt($encrypted_text);
173
+		}
174
+		return $decrypted_text;
175
+	}
176
+
177
+
178
+
179
+	/**
180
+	 * encodes string with PHP's base64 encoding
181
+	 *
182
+	 * @see http://php.net/manual/en/function.base64-encode.php
183
+	 * @param string $text_string the text to be encoded
184
+	 * @return string
185
+	 */
186
+	public function base64_string_encode($text_string = '')
187
+	{
188
+		// you give me nothing??? GET OUT !
189
+		if (empty($text_string) || ! $this->_use_base64_encode) {
190
+			return $text_string;
191
+		}
192
+		// encode
193
+		return base64_encode($text_string);
194
+	}
195
+
196
+
197
+
198
+	/**
199
+	 * decodes string that has been encoded with PHP's base64 encoding
200
+	 *
201
+	 * @see http://php.net/manual/en/function.base64-encode.php
202
+	 * @param string $encoded_string the text to be decoded
203
+	 * @return string
204
+	 */
205
+	public function base64_string_decode($encoded_string = '')
206
+	{
207
+		// you give me nothing??? GET OUT !
208
+		if (empty($encoded_string) || ! $this->valid_base_64($encoded_string)) {
209
+			return $encoded_string;
210
+		}
211
+		// decode
212
+		return base64_decode($encoded_string);
213
+	}
214
+
215
+
216
+
217
+	/**
218
+	 * encodes  url string with PHP's base64 encoding
219
+	 *
220
+	 * @see http://php.net/manual/en/function.base64-encode.php
221
+	 * @param string $text_string the text to be encoded
222
+	 * @return string
223
+	 */
224
+	public function base64_url_encode($text_string = '')
225
+	{
226
+		// you give me nothing??? GET OUT !
227
+		if (empty($text_string) || ! $this->_use_base64_encode) {
228
+			return $text_string;
229
+		}
230
+		// encode
231
+		$encoded_string = base64_encode($text_string);
232
+		// remove chars to make encoding more URL friendly
233
+		return strtr($encoded_string, '+/=', '-_,');
234
+	}
235
+
236
+
237
+
238
+	/**
239
+	 * decodes  url string that has been encoded with PHP's base64 encoding
240
+	 *
241
+	 * @see http://php.net/manual/en/function.base64-encode.php
242
+	 * @param string $encoded_string the text to be decoded
243
+	 * @return string
244
+	 */
245
+	public function base64_url_decode($encoded_string = '')
246
+	{
247
+		// you give me nothing??? GET OUT !
248
+		if (empty($encoded_string) || ! $this->valid_base_64($encoded_string)) {
249
+			return $encoded_string;
250
+		}
251
+		// replace previously removed characters
252
+		$encoded_string = strtr($encoded_string, '-_,', '+/=');
253
+		// decode
254
+		return base64_decode($encoded_string);
255
+	}
256
+
257
+
258
+
259
+	/**
260
+	 * encrypts data using PHP's openssl functions
261
+	 *
262
+	 * @param string $text_string the text to be encrypted
263
+	 * @return string
264
+	 * @throws RuntimeException
265
+	 */
266
+	protected function openssl_encrypt($text_string = '')
267
+	{
268
+		// you give me nothing??? GET OUT !
269
+		if (empty($text_string)) {
270
+			return $text_string;
271
+		}
272
+		// get initialization vector size
273
+		$iv_size = openssl_cipher_iv_length(EE_Encryption::OPENSSL_CIPHER_METHOD);
274
+		// generate initialization vector
275
+		$iv = openssl_random_pseudo_bytes($iv_size, $is_strong);
276
+		if ($iv === false || $is_strong === false) {
277
+			throw new RuntimeException(
278
+				esc_html__('Failed to generate OpenSSL initialization vector.', 'event_espresso')
279
+			);
280
+		}
281
+		// encrypt it
282
+		$encrypted_text = openssl_encrypt(
283
+			$text_string,
284
+			EE_Encryption::OPENSSL_CIPHER_METHOD,
285
+			openssl_digest($this->get_encryption_key(), EE_Encryption::OPENSSL_DIGEST_METHOD),
286
+			0,
287
+			$iv
288
+		);
289
+		// append the initialization vector
290
+		$encrypted_text .= EE_Encryption::OPENSSL_IV_DELIMITER . $iv;
291
+		// trim and maybe encode
292
+		return $this->_use_base64_encode
293
+			? trim(base64_encode($encrypted_text))
294
+			: trim($encrypted_text);
295
+	}
296
+
297
+
298
+
299
+	/**
300
+	 * decrypts data that has been encrypted with PHP's openssl functions
301
+	 *
302
+	 * @param string $encrypted_text the text to be decrypted
303
+	 * @return string
304
+	 * @throws RuntimeException
305
+	 */
306
+	protected function openssl_decrypt($encrypted_text = '')
307
+	{
308
+		// you give me nothing??? GET OUT !
309
+		if (empty($encrypted_text)) {
310
+			return $encrypted_text;
311
+		}
312
+		// decode
313
+		$encrypted_text = $this->valid_base_64($encrypted_text)
314
+			? base64_decode($encrypted_text)
315
+			: $encrypted_text;
316
+		$encrypted_components = explode(
317
+			EE_Encryption::OPENSSL_IV_DELIMITER,
318
+			$encrypted_text,
319
+			2
320
+		);
321
+		// check that iv exists, and if not, maybe text was encoded using mcrypt?
322
+		if (! isset($encrypted_components[1]) && $this->_use_mcrypt) {
323
+			return $this->m_decrypt($encrypted_text);
324
+		}
325
+		// decrypt it
326
+		$decrypted_text = openssl_decrypt(
327
+			$encrypted_components[0],
328
+			EE_Encryption::OPENSSL_CIPHER_METHOD,
329
+			openssl_digest($this->get_encryption_key(), EE_Encryption::OPENSSL_DIGEST_METHOD),
330
+			0,
331
+			$encrypted_components[1]
332
+		);
333
+		$decrypted_text = trim($decrypted_text);
334
+		return $decrypted_text;
335
+	}
336
+
337
+
338
+
339
+	/**
340
+	 * encrypts data for acme servers that didn't bother to install PHP mcrypt
341
+	 *
342
+	 * @see http://stackoverflow.com/questions/800922/how-to-encrypt-string-without-mcrypt-library-in-php
343
+	 * @param string $text_string the text to be decrypted
344
+	 * @return string
345
+	 */
346
+	protected function acme_encrypt($text_string = '')
347
+	{
348
+		// you give me nothing??? GET OUT !
349
+		if (empty($text_string)) {
350
+			return $text_string;
351
+		}
352
+		$key_bits = str_split(
353
+			str_pad('', strlen($text_string), $this->get_encryption_key(), STR_PAD_RIGHT)
354
+		);
355
+		$string_bits = str_split($text_string);
356
+		foreach ($string_bits as $k => $v) {
357
+			$temp = ord($v) + ord($key_bits[$k]);
358
+			$string_bits[$k] = chr($temp > 255 ? ($temp - 256) : $temp);
359
+		}
360
+		return $this->_use_base64_encode
361
+			? base64_encode(implode('', $string_bits))
362
+			: implode('', $string_bits);
363
+	}
364
+
365
+
366
+
367
+	/**
368
+	 * decrypts data for acme servers that didn't bother to install PHP mcrypt
369
+	 *
370
+	 * @see http://stackoverflow.com/questions/800922/how-to-encrypt-string-without-mcrypt-library-in-php
371
+	 * @param string $encrypted_text the text to be decrypted
372
+	 * @return string
373
+	 */
374
+	protected function acme_decrypt($encrypted_text = '')
375
+	{
376
+		// you give me nothing??? GET OUT !
377
+		if (empty($encrypted_text)) {
378
+			return $encrypted_text;
379
+		}
380
+		// decode the data ?
381
+		$encrypted_text = $this->valid_base_64($encrypted_text)
382
+			? base64_decode($encrypted_text)
383
+			: $encrypted_text;
384
+		$key_bits = str_split(
385
+			str_pad('', strlen($encrypted_text), $this->get_encryption_key(), STR_PAD_RIGHT)
386
+		);
387
+		$string_bits = str_split($encrypted_text);
388
+		foreach ($string_bits as $k => $v) {
389
+			$temp = ord($v) - ord($key_bits[$k]);
390
+			$string_bits[$k] = chr($temp < 0 ? ($temp + 256) : $temp);
391
+		}
392
+		return implode('', $string_bits);
393
+	}
394
+
395
+
396
+
397
+	/**
398
+	 * @see http://stackoverflow.com/questions/2556345/detect-base64-encoding-in-php#30231906
399
+	 * @param $string
400
+	 * @return bool
401
+	 */
402
+	protected function valid_base_64($string)
403
+	{
404
+		// ensure data is a string
405
+		if (! is_string($string) || ! $this->_use_base64_encode) {
406
+			return false;
407
+		}
408
+		$decoded = base64_decode($string, true);
409
+		// Check if there is no invalid character in string
410
+		if (! preg_match('/^[a-zA-Z0-9\/\r\n+]*={0,2}$/', $string)) {
411
+			return false;
412
+		}
413
+		// Decode the string in strict mode and send the response
414
+		if (! base64_decode($string, true)) {
415
+			return false;
416
+		}
417
+		// Encode and compare it to original one
418
+		return base64_encode($decoded) === $string;
419
+	}
420
+
421
+
422
+
423
+	/**
424
+	 * generate random string
425
+	 *
426
+	 * @see http://stackoverflow.com/questions/637278/what-is-the-best-way-to-generate-a-random-key-within-php
427
+	 * @param int $length number of characters for random string
428
+	 * @return string
429
+	 */
430
+	public function generate_random_string($length = 40)
431
+	{
432
+		$iterations = ceil($length / 40);
433
+		$random_string = '';
434
+		for ($i = 0; $i < $iterations; $i++) {
435
+			$random_string .= sha1(microtime(true) . mt_rand(10000, 90000));
436
+		}
437
+		$random_string = substr($random_string, 0, $length);
438
+		return $random_string;
439
+	}
440
+
441
+
442
+
443
+	/**
444
+	 * encrypts data using PHP's mcrypt functions
445
+	 *
446
+	 * @deprecated 4.9.39
447
+	 * @param string $text_string
448
+	 * @internal   param $string - the text to be encrypted
449
+	 * @return string
450
+	 * @throws RuntimeException
451
+	 */
452
+	protected function m_encrypt($text_string = '')
453
+	{
454
+		// you give me nothing??? GET OUT !
455
+		if (empty($text_string)) {
456
+			return $text_string;
457
+		}
458
+		// get the initialization vector size
459
+		$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
460
+		// initialization vector
461
+		$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
462
+		if ($iv === false) {
463
+			throw new RuntimeException(
464
+				esc_html__('Failed to generate mcrypt initialization vector.', 'event_espresso')
465
+			);
466
+		}
467
+		// encrypt it
468
+		$encrypted_text = mcrypt_encrypt(
469
+			MCRYPT_RIJNDAEL_256,
470
+			$this->get_encryption_key(),
471
+			$text_string,
472
+			MCRYPT_MODE_ECB,
473
+			$iv
474
+		);
475
+		// trim and maybe encode
476
+		return $this->_use_base64_encode
477
+			? trim(base64_encode($encrypted_text))
478
+			: trim($encrypted_text);
479
+	}
480
+
481
+
482
+
483
+	/**
484
+	 * decrypts data that has been encrypted with PHP's mcrypt functions
485
+	 *
486
+	 * @deprecated 4.9.39
487
+	 * @param string $encrypted_text the text to be decrypted
488
+	 * @return string
489
+	 * @throws RuntimeException
490
+	 */
491
+	protected function m_decrypt($encrypted_text = '')
492
+	{
493
+		// you give me nothing??? GET OUT !
494
+		if (empty($encrypted_text)) {
495
+			return $encrypted_text;
496
+		}
497
+		// decode
498
+		$encrypted_text = $this->valid_base_64($encrypted_text)
499
+			? base64_decode($encrypted_text)
500
+			: $encrypted_text;
501
+		// get the initialization vector size
502
+		$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
503
+		$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
504
+		if ($iv === false) {
505
+			throw new RuntimeException(
506
+				esc_html__('Failed to generate mcrypt initialization vector.', 'event_espresso')
507
+			);
508
+		}
509
+		// decrypt it
510
+		$decrypted_text = mcrypt_decrypt(
511
+			MCRYPT_RIJNDAEL_256,
512
+			$this->get_encryption_key(),
513
+			$encrypted_text,
514
+			MCRYPT_MODE_ECB,
515
+			$iv
516
+		);
517
+		$decrypted_text = trim($decrypted_text);
518
+		return $decrypted_text;
519
+	}
520 520
 
521 521
 }
522 522
 /* End of file EE_Encryption.class.php */
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
      */
71 71
     protected function __construct()
72 72
     {
73
-        if (! defined('ESPRESSO_ENCRYPT')) {
73
+        if ( ! defined('ESPRESSO_ENCRYPT')) {
74 74
             define('ESPRESSO_ENCRYPT', true);
75 75
         }
76 76
         if (extension_loaded('openssl')) {
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
     public static function instance()
94 94
     {
95 95
         // check if class object is instantiated
96
-        if (! self::$_instance instanceof EE_Encryption) {
96
+        if ( ! self::$_instance instanceof EE_Encryption) {
97 97
             self::$_instance = new self();
98 98
         }
99 99
         return self::$_instance;
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
             $iv
288 288
         );
289 289
         // append the initialization vector
290
-        $encrypted_text .= EE_Encryption::OPENSSL_IV_DELIMITER . $iv;
290
+        $encrypted_text .= EE_Encryption::OPENSSL_IV_DELIMITER.$iv;
291 291
         // trim and maybe encode
292 292
         return $this->_use_base64_encode
293 293
             ? trim(base64_encode($encrypted_text))
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
             2
320 320
         );
321 321
         // check that iv exists, and if not, maybe text was encoded using mcrypt?
322
-        if (! isset($encrypted_components[1]) && $this->_use_mcrypt) {
322
+        if ( ! isset($encrypted_components[1]) && $this->_use_mcrypt) {
323 323
             return $this->m_decrypt($encrypted_text);
324 324
         }
325 325
         // decrypt it
@@ -402,16 +402,16 @@  discard block
 block discarded – undo
402 402
     protected function valid_base_64($string)
403 403
     {
404 404
         // ensure data is a string
405
-        if (! is_string($string) || ! $this->_use_base64_encode) {
405
+        if ( ! is_string($string) || ! $this->_use_base64_encode) {
406 406
             return false;
407 407
         }
408 408
         $decoded = base64_decode($string, true);
409 409
         // Check if there is no invalid character in string
410
-        if (! preg_match('/^[a-zA-Z0-9\/\r\n+]*={0,2}$/', $string)) {
410
+        if ( ! preg_match('/^[a-zA-Z0-9\/\r\n+]*={0,2}$/', $string)) {
411 411
             return false;
412 412
         }
413 413
         // Decode the string in strict mode and send the response
414
-        if (! base64_decode($string, true)) {
414
+        if ( ! base64_decode($string, true)) {
415 415
             return false;
416 416
         }
417 417
         // Encode and compare it to original one
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
         $iterations = ceil($length / 40);
433 433
         $random_string = '';
434 434
         for ($i = 0; $i < $iterations; $i++) {
435
-            $random_string .= sha1(microtime(true) . mt_rand(10000, 90000));
435
+            $random_string .= sha1(microtime(true).mt_rand(10000, 90000));
436 436
         }
437 437
         $random_string = substr($random_string, 0, $length);
438 438
         return $random_string;
Please login to merge, or discard this patch.
acceptance_tests/Helpers/BaseCoreAdmin.php 1 patch
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -13,39 +13,39 @@
 block discarded – undo
13 13
 trait BaseCoreAdmin
14 14
 {
15 15
 
16
-    /**
17
-     * Core method for going to an Event Espresso Admin page.
18
-     * @param string $page
19
-     * @param string $action
20
-     * @param string $additional_params
21
-     */
22
-    public function amOnEventEspressoAdminPage($page = '', $action = '', $additional_params = '')
23
-    {
24
-        $this->actor()->amOnAdminPage(CoreAdmin::adminUrl($page, $action, $additional_params));
25
-    }
16
+	/**
17
+	 * Core method for going to an Event Espresso Admin page.
18
+	 * @param string $page
19
+	 * @param string $action
20
+	 * @param string $additional_params
21
+	 */
22
+	public function amOnEventEspressoAdminPage($page = '', $action = '', $additional_params = '')
23
+	{
24
+		$this->actor()->amOnAdminPage(CoreAdmin::adminUrl($page, $action, $additional_params));
25
+	}
26 26
 
27 27
 
28
-    /**
29
-     * Helper method for returning an instance of the Actor.  Intended to help with IDE fill out of methods.
30
-     * @return \EventEspressoAcceptanceTester;
31
-     */
32
-    protected function actor()
33
-    {
34
-        /** @var \EventEspressoAcceptanceTester $this */
35
-        return $this;
36
-    }
28
+	/**
29
+	 * Helper method for returning an instance of the Actor.  Intended to help with IDE fill out of methods.
30
+	 * @return \EventEspressoAcceptanceTester;
31
+	 */
32
+	protected function actor()
33
+	{
34
+		/** @var \EventEspressoAcceptanceTester $this */
35
+		return $this;
36
+	}
37 37
 
38 38
 
39
-    /**
40
-     * Use this to set the per page option for a list table page.
41
-     * Assumes you are on a page that has this field exposed.
42
-     * @param int|string $per_page_value
43
-     */
44
-    public function setPerPageOptionForScreen($per_page_value)
45
-    {
46
-        $this->actor()->click(CoreAdmin::WP_SCREEN_SETTINGS_LINK_SELECTOR);
47
-        $this->actor()->fillField(CoreAdmin::WP_SCREEN_SETTINGS_PER_PAGE_FIELD_SELECTOR, $per_page_value);
48
-        $this->actor()->click(CoreAdmin::WP_SCREEN_OPTIONS_APPLY_SETTINGS_BUTTON_SELECTOR);
49
-        $this->actor()->wait(8);
50
-    }
39
+	/**
40
+	 * Use this to set the per page option for a list table page.
41
+	 * Assumes you are on a page that has this field exposed.
42
+	 * @param int|string $per_page_value
43
+	 */
44
+	public function setPerPageOptionForScreen($per_page_value)
45
+	{
46
+		$this->actor()->click(CoreAdmin::WP_SCREEN_SETTINGS_LINK_SELECTOR);
47
+		$this->actor()->fillField(CoreAdmin::WP_SCREEN_SETTINGS_PER_PAGE_FIELD_SELECTOR, $per_page_value);
48
+		$this->actor()->click(CoreAdmin::WP_SCREEN_OPTIONS_APPLY_SETTINGS_BUTTON_SELECTOR);
49
+		$this->actor()->wait(8);
50
+	}
51 51
 }
52 52
\ No newline at end of file
Please login to merge, or discard this patch.
acceptance_tests/Page/CoreAdmin.php 1 patch
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -13,63 +13,63 @@
 block discarded – undo
13 13
 class CoreAdmin
14 14
 {
15 15
 
16
-    /**
17
-     * @var string
18
-     */
19
-    const URL_PREFIX = 'admin.php?page=';
16
+	/**
17
+	 * @var string
18
+	 */
19
+	const URL_PREFIX = 'admin.php?page=';
20 20
 
21 21
 
22
-    /**
23
-     * This is the selector for the next page button on list tables.
24
-     * @var string
25
-     */
26
-    const ADMIN_LIST_TABLE_NEXT_PAGE_CLASS = '.next-page';
22
+	/**
23
+	 * This is the selector for the next page button on list tables.
24
+	 * @var string
25
+	 */
26
+	const ADMIN_LIST_TABLE_NEXT_PAGE_CLASS = '.next-page';
27 27
 
28 28
 
29
-    /**
30
-     * The selector for the search input submit button on list table pages
31
-     * @var string
32
-     */
33
-    const LIST_TABLE_SEARCH_SUBMIT_SELECTOR = '#search-submit';
29
+	/**
30
+	 * The selector for the search input submit button on list table pages
31
+	 * @var string
32
+	 */
33
+	const LIST_TABLE_SEARCH_SUBMIT_SELECTOR = '#search-submit';
34 34
 
35 35
 
36
-    /**
37
-     * Selector for the screen options dropdown.
38
-     * @var string
39
-     */
40
-    const WP_SCREEN_SETTINGS_LINK_SELECTOR = '#show-settings-link';
36
+	/**
37
+	 * Selector for the screen options dropdown.
38
+	 * @var string
39
+	 */
40
+	const WP_SCREEN_SETTINGS_LINK_SELECTOR = '#show-settings-link';
41 41
 
42 42
 
43
-    /**
44
-     * Selector for the per page field setting selector (found within screen options dropdown)
45
-     * @var string
46
-     */
47
-    const WP_SCREEN_SETTINGS_PER_PAGE_FIELD_SELECTOR = '.screen-per-page';
43
+	/**
44
+	 * Selector for the per page field setting selector (found within screen options dropdown)
45
+	 * @var string
46
+	 */
47
+	const WP_SCREEN_SETTINGS_PER_PAGE_FIELD_SELECTOR = '.screen-per-page';
48 48
 
49 49
 
50
-    /**
51
-     * Selector for apply screen options settings.
52
-     * @var string
53
-     */
54
-    const WP_SCREEN_OPTIONS_APPLY_SETTINGS_BUTTON_SELECTOR = '#screen-options-apply';
50
+	/**
51
+	 * Selector for apply screen options settings.
52
+	 * @var string
53
+	 */
54
+	const WP_SCREEN_OPTIONS_APPLY_SETTINGS_BUTTON_SELECTOR = '#screen-options-apply';
55 55
 
56 56
 
57
-    /**
58
-     * Get the EE admin url for the given properties.
59
-     * Note, this is JUST the endpoint for the admin route.  It is expected that the actor/test would be calling this
60
-     * with `amOnAdminPage` action.
61
-     *
62
-     * @param string $page
63
-     * @param string $action
64
-     * @param string $additional_params
65
-     * @return string
66
-     */
67
-    public static function adminUrl($page = 'espresso_events', $action = 'default', $additional_params = '')
68
-    {
69
-        $url = self::URL_PREFIX . $page;
70
-        $url .= $action ? '&action=' . $action : '';
71
-        $url .= $additional_params ? '&' . ltrim('&', ltrim('?', $additional_params)) : '';
72
-        return $url;
73
-    }
57
+	/**
58
+	 * Get the EE admin url for the given properties.
59
+	 * Note, this is JUST the endpoint for the admin route.  It is expected that the actor/test would be calling this
60
+	 * with `amOnAdminPage` action.
61
+	 *
62
+	 * @param string $page
63
+	 * @param string $action
64
+	 * @param string $additional_params
65
+	 * @return string
66
+	 */
67
+	public static function adminUrl($page = 'espresso_events', $action = 'default', $additional_params = '')
68
+	{
69
+		$url = self::URL_PREFIX . $page;
70
+		$url .= $action ? '&action=' . $action : '';
71
+		$url .= $additional_params ? '&' . ltrim('&', ltrim('?', $additional_params)) : '';
72
+		return $url;
73
+	}
74 74
 
75 75
 }
76 76
\ No newline at end of file
Please login to merge, or discard this patch.
acceptance_tests/Page/EventsAdmin.php 1 patch
Indentation   +132 added lines, -132 removed lines patch added patch discarded remove patch
@@ -14,136 +14,136 @@
 block discarded – undo
14 14
 class EventsAdmin extends CoreAdmin
15 15
 {
16 16
 
17
-    /**
18
-     * Selector for the Add new Event button in the admin.
19
-     * @var string
20
-     */
21
-    const ADD_NEW_EVENT_BUTTON_SELECTOR = '#add-new-event';
22
-
23
-
24
-    /**
25
-     * Selector for the Event Title field in the event editor
26
-     * @var string
27
-     */
28
-    const EVENT_EDITOR_TITLE_FIELD_SELECTOR = "//input[@id='title']";
29
-
30
-    /**
31
-     * Selector for the publish submit button in the event editor.
32
-     * @var string
33
-     */
34
-    const EVENT_EDITOR_PUBLISH_BUTTON_SELECTOR = "#publish";
35
-
36
-    /**
37
-     * Selector for the view link after publishing an event.
38
-     * @var string
39
-     */
40
-    const EVENT_EDITOR_VIEW_LINK_AFTER_PUBLISH_SELECTOR = "//div[@id='message']/p/a";
41
-
42
-
43
-    /**
44
-     * Selector for the ID of the event in the event editor
45
-     * @var string
46
-     */
47
-    const EVENT_EDITOR_EVT_ID_SELECTOR = "//input[@id='post_ID']";
48
-
49
-
50
-    /**
51
-     * Selector for the search input on the event list table page.
52
-     * @var string
53
-     */
54
-    const EVENT_LIST_TABLE_SEARCH_INPUT_SELECTOR = '#toplevel_page_espresso_events-search-input';
55
-
56
-
57
-
58
-    /**
59
-     * @param string $additional_params
60
-     * @return string
61
-     */
62
-    public static function defaultEventsListTableUrl($additional_params = '')
63
-    {
64
-        return self::adminUrl('espresso_events', 'default', $additional_params);
65
-    }
66
-
67
-
68
-    /**
69
-     * The selector for the DTTname field for the given row in the event editor.
70
-     * @param int $row_number
71
-     * @return string
72
-     */
73
-    public static function eventEditorDatetimeNameFieldSelector($row_number = 1)
74
-    {
75
-        return self::eventEditorDatetimeFieldSelectorForField('DTT_name', $row_number);
76
-    }
77
-
78
-
79
-    /**
80
-     * The selector for the DTT_EVT_start field for the given row in the event editor.d
81
-     * @param int $row_number
82
-     * @return string
83
-     */
84
-    public static function eventEditorDatetimeStartDateFieldSelector($row_number = 1)
85
-    {
86
-        return self::eventEditorDatetimeFieldSelectorForField('DTT_EVT_start', $row_number);
87
-    }
88
-
89
-
90
-    /**
91
-     * Wrapper for getting the selector for a given field and given row of a datetime in the event editor.
92
-     *
93
-     * @param string $field_name
94
-     * @param int    $row_number
95
-     * @return string
96
-     */
97
-    public static function eventEditorDatetimeFieldSelectorForField($field_name, $row_number = 1)
98
-    {
99
-        return "//input[@id='event-datetime-$field_name-$row_number']";
100
-    }
101
-
102
-
103
-    /**
104
-     * The selector for the TKT_name field for the given display row in the event editor.
105
-     * @param int $row_number
106
-     * @return string
107
-     */
108
-    public static function eventEditorTicketNameFieldSelector($row_number = 1)
109
-    {
110
-        return self::eventEditorTicketFieldSelectorForFieldInDisplayRow('TKT_name', $row_number);
111
-    }
112
-
113
-
114
-    /**
115
-     * Wrapper for getting the selector for a given field and given display row of a ticket in the event editor.
116
-     * @param     $field_name
117
-     * @param int $row_number
118
-     * @return string
119
-     */
120
-    public static function eventEditorTicketFieldSelectorForFieldInDisplayRow($field_name, $row_number = 1)
121
-    {
122
-        return "//tr[@id='display-ticketrow-$row_number']/td[2]/input[@class='edit-ticket-$field_name ee-large-text-inp']";
123
-    }
124
-
125
-
126
-    /**
127
-     * Returns the selector for the event title edit link in the events list table for the given Event Title.
128
-     * @param string $event_title
129
-     * @return string
130
-     */
131
-    public static function eventListTableEventTitleEditLinkSelectorForTitle($event_title)
132
-    {
133
-        return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']";
134
-    }
135
-
136
-
137
-    public static function eventListTableEventIdSelectorForTitle($event_title)
138
-    {
139
-        return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']"
140
-            . "//ancestor::tr/th[contains(@class, 'check-column')]/input";
141
-    }
142
-
143
-
144
-    public static function eventListTableEventTitleViewLinkSelectorForTitle($event_title)
145
-    {
146
-        return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']"
147
-            . "//ancestor::td//span[@class='view']/a";
148
-    }
17
+	/**
18
+	 * Selector for the Add new Event button in the admin.
19
+	 * @var string
20
+	 */
21
+	const ADD_NEW_EVENT_BUTTON_SELECTOR = '#add-new-event';
22
+
23
+
24
+	/**
25
+	 * Selector for the Event Title field in the event editor
26
+	 * @var string
27
+	 */
28
+	const EVENT_EDITOR_TITLE_FIELD_SELECTOR = "//input[@id='title']";
29
+
30
+	/**
31
+	 * Selector for the publish submit button in the event editor.
32
+	 * @var string
33
+	 */
34
+	const EVENT_EDITOR_PUBLISH_BUTTON_SELECTOR = "#publish";
35
+
36
+	/**
37
+	 * Selector for the view link after publishing an event.
38
+	 * @var string
39
+	 */
40
+	const EVENT_EDITOR_VIEW_LINK_AFTER_PUBLISH_SELECTOR = "//div[@id='message']/p/a";
41
+
42
+
43
+	/**
44
+	 * Selector for the ID of the event in the event editor
45
+	 * @var string
46
+	 */
47
+	const EVENT_EDITOR_EVT_ID_SELECTOR = "//input[@id='post_ID']";
48
+
49
+
50
+	/**
51
+	 * Selector for the search input on the event list table page.
52
+	 * @var string
53
+	 */
54
+	const EVENT_LIST_TABLE_SEARCH_INPUT_SELECTOR = '#toplevel_page_espresso_events-search-input';
55
+
56
+
57
+
58
+	/**
59
+	 * @param string $additional_params
60
+	 * @return string
61
+	 */
62
+	public static function defaultEventsListTableUrl($additional_params = '')
63
+	{
64
+		return self::adminUrl('espresso_events', 'default', $additional_params);
65
+	}
66
+
67
+
68
+	/**
69
+	 * The selector for the DTTname field for the given row in the event editor.
70
+	 * @param int $row_number
71
+	 * @return string
72
+	 */
73
+	public static function eventEditorDatetimeNameFieldSelector($row_number = 1)
74
+	{
75
+		return self::eventEditorDatetimeFieldSelectorForField('DTT_name', $row_number);
76
+	}
77
+
78
+
79
+	/**
80
+	 * The selector for the DTT_EVT_start field for the given row in the event editor.d
81
+	 * @param int $row_number
82
+	 * @return string
83
+	 */
84
+	public static function eventEditorDatetimeStartDateFieldSelector($row_number = 1)
85
+	{
86
+		return self::eventEditorDatetimeFieldSelectorForField('DTT_EVT_start', $row_number);
87
+	}
88
+
89
+
90
+	/**
91
+	 * Wrapper for getting the selector for a given field and given row of a datetime in the event editor.
92
+	 *
93
+	 * @param string $field_name
94
+	 * @param int    $row_number
95
+	 * @return string
96
+	 */
97
+	public static function eventEditorDatetimeFieldSelectorForField($field_name, $row_number = 1)
98
+	{
99
+		return "//input[@id='event-datetime-$field_name-$row_number']";
100
+	}
101
+
102
+
103
+	/**
104
+	 * The selector for the TKT_name field for the given display row in the event editor.
105
+	 * @param int $row_number
106
+	 * @return string
107
+	 */
108
+	public static function eventEditorTicketNameFieldSelector($row_number = 1)
109
+	{
110
+		return self::eventEditorTicketFieldSelectorForFieldInDisplayRow('TKT_name', $row_number);
111
+	}
112
+
113
+
114
+	/**
115
+	 * Wrapper for getting the selector for a given field and given display row of a ticket in the event editor.
116
+	 * @param     $field_name
117
+	 * @param int $row_number
118
+	 * @return string
119
+	 */
120
+	public static function eventEditorTicketFieldSelectorForFieldInDisplayRow($field_name, $row_number = 1)
121
+	{
122
+		return "//tr[@id='display-ticketrow-$row_number']/td[2]/input[@class='edit-ticket-$field_name ee-large-text-inp']";
123
+	}
124
+
125
+
126
+	/**
127
+	 * Returns the selector for the event title edit link in the events list table for the given Event Title.
128
+	 * @param string $event_title
129
+	 * @return string
130
+	 */
131
+	public static function eventListTableEventTitleEditLinkSelectorForTitle($event_title)
132
+	{
133
+		return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']";
134
+	}
135
+
136
+
137
+	public static function eventListTableEventIdSelectorForTitle($event_title)
138
+	{
139
+		return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']"
140
+			. "//ancestor::tr/th[contains(@class, 'check-column')]/input";
141
+	}
142
+
143
+
144
+	public static function eventListTableEventTitleViewLinkSelectorForTitle($event_title)
145
+	{
146
+		return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']"
147
+			. "//ancestor::td//span[@class='view']/a";
148
+	}
149 149
 }
150 150
\ No newline at end of file
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +219 added lines, -219 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('ABSPATH')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /*
5 5
   Plugin Name:		Event Espresso
@@ -40,243 +40,243 @@  discard block
 block discarded – undo
40 40
  * @since            4.0
41 41
  */
42 42
 if (function_exists('espresso_version')) {
43
-    /**
44
-     *    espresso_duplicate_plugin_error
45
-     *    displays if more than one version of EE is activated at the same time
46
-     */
47
-    function espresso_duplicate_plugin_error()
48
-    {
49
-        ?>
43
+	/**
44
+	 *    espresso_duplicate_plugin_error
45
+	 *    displays if more than one version of EE is activated at the same time
46
+	 */
47
+	function espresso_duplicate_plugin_error()
48
+	{
49
+		?>
50 50
         <div class="error">
51 51
             <p>
52 52
                 <?php echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                ); ?>
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+				); ?>
56 56
             </p>
57 57
         </div>
58 58
         <?php
59
-        espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-    }
59
+		espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+	}
61 61
 
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 } else {
64
-    define('EE_MIN_PHP_VER_REQUIRED', '5.3.9');
65
-    if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
-        /**
67
-         * espresso_minimum_php_version_error
68
-         *
69
-         * @return void
70
-         */
71
-        function espresso_minimum_php_version_error()
72
-        {
73
-            ?>
64
+	define('EE_MIN_PHP_VER_REQUIRED', '5.3.9');
65
+	if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
66
+		/**
67
+		 * espresso_minimum_php_version_error
68
+		 *
69
+		 * @return void
70
+		 */
71
+		function espresso_minimum_php_version_error()
72
+		{
73
+			?>
74 74
             <div class="error">
75 75
                 <p>
76 76
                     <?php
77
-                    printf(
78
-                            esc_html__(
79
-                                    'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
-                                    'event_espresso'
81
-                            ),
82
-                            EE_MIN_PHP_VER_REQUIRED,
83
-                            PHP_VERSION,
84
-                            '<br/>',
85
-                            '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
-                    );
87
-                    ?>
77
+					printf(
78
+							esc_html__(
79
+									'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
80
+									'event_espresso'
81
+							),
82
+							EE_MIN_PHP_VER_REQUIRED,
83
+							PHP_VERSION,
84
+							'<br/>',
85
+							'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
86
+					);
87
+					?>
88 88
                 </p>
89 89
             </div>
90 90
             <?php
91
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
92
-        }
91
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
92
+		}
93 93
 
94
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
-    } else {
96
-        /**
97
-         * espresso_version
98
-         * Returns the plugin version
99
-         *
100
-         * @return string
101
-         */
102
-        function espresso_version()
103
-        {
104
-            return apply_filters('FHEE__espresso__espresso_version', '4.9.39.rc.044');
105
-        }
94
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
95
+	} else {
96
+		/**
97
+		 * espresso_version
98
+		 * Returns the plugin version
99
+		 *
100
+		 * @return string
101
+		 */
102
+		function espresso_version()
103
+		{
104
+			return apply_filters('FHEE__espresso__espresso_version', '4.9.39.rc.044');
105
+		}
106 106
 
107
-        // define versions
108
-        define('EVENT_ESPRESSO_VERSION', espresso_version());
109
-        define('EE_MIN_WP_VER_REQUIRED', '4.1');
110
-        define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2');
111
-        define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44');
112
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
113
-        //used to be DIRECTORY_SEPARATOR, but that caused issues on windows
114
-        if ( ! defined('DS')) {
115
-            define('DS', '/');
116
-        }
117
-        if ( ! defined('PS')) {
118
-            define('PS', PATH_SEPARATOR);
119
-        }
120
-        if ( ! defined('SP')) {
121
-            define('SP', ' ');
122
-        }
123
-        if ( ! defined('EENL')) {
124
-            define('EENL', "\n");
125
-        }
126
-        define('EE_SUPPORT_EMAIL', '[email protected]');
127
-        // define the plugin directory and URL
128
-        define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE));
129
-        define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE));
130
-        define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE));
131
-        // main root folder paths
132
-        define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS);
133
-        define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS);
134
-        define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS);
135
-        define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS);
136
-        define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS);
137
-        define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS);
138
-        define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS);
139
-        define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS);
140
-        // core system paths
141
-        define('EE_ADMIN', EE_CORE . 'admin' . DS);
142
-        define('EE_CPTS', EE_CORE . 'CPTs' . DS);
143
-        define('EE_CLASSES', EE_CORE . 'db_classes' . DS);
144
-        define('EE_INTERFACES', EE_CORE . 'interfaces' . DS);
145
-        define('EE_BUSINESS', EE_CORE . 'business' . DS);
146
-        define('EE_MODELS', EE_CORE . 'db_models' . DS);
147
-        define('EE_HELPERS', EE_CORE . 'helpers' . DS);
148
-        define('EE_LIBRARIES', EE_CORE . 'libraries' . DS);
149
-        define('EE_TEMPLATES', EE_CORE . 'templates' . DS);
150
-        define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS);
151
-        define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS);
152
-        define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS);
153
-        // gateways
154
-        define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS);
155
-        define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS);
156
-        // asset URL paths
157
-        define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS);
158
-        define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS);
159
-        define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS);
160
-        define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS);
161
-        define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/');
162
-        define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/');
163
-        // define upload paths
164
-        $uploads = wp_upload_dir();
165
-        // define the uploads directory and URL
166
-        define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS);
167
-        define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS);
168
-        // define the templates directory and URL
169
-        define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS);
170
-        define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS);
171
-        // define the gateway directory and URL
172
-        define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS);
173
-        define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS);
174
-        // languages folder/path
175
-        define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS);
176
-        define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS);
177
-        //check for dompdf fonts in uploads
178
-        if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) {
179
-            define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS);
180
-        }
181
-        //ajax constants
182
-        define(
183
-                'EE_FRONT_AJAX',
184
-                isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false
185
-        );
186
-        define(
187
-                'EE_ADMIN_AJAX',
188
-                isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false
189
-        );
190
-        //just a handy constant occasionally needed for finding values representing infinity in the DB
191
-        //you're better to use this than its straight value (currently -1) in case you ever
192
-        //want to change its default value! or find when -1 means infinity
193
-        define('EE_INF_IN_DB', -1);
194
-        define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX);
195
-        define('EE_DEBUG', false);
196
-        // for older WP versions
197
-        if ( ! defined('MONTH_IN_SECONDS')) {
198
-            define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30);
199
-        }
200
-        /**
201
-         *    espresso_plugin_activation
202
-         *    adds a wp-option to indicate that EE has been activated via the WP admin plugins page
203
-         */
204
-        function espresso_plugin_activation()
205
-        {
206
-            update_option('ee_espresso_activation', true);
207
-        }
107
+		// define versions
108
+		define('EVENT_ESPRESSO_VERSION', espresso_version());
109
+		define('EE_MIN_WP_VER_REQUIRED', '4.1');
110
+		define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2');
111
+		define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44');
112
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
113
+		//used to be DIRECTORY_SEPARATOR, but that caused issues on windows
114
+		if ( ! defined('DS')) {
115
+			define('DS', '/');
116
+		}
117
+		if ( ! defined('PS')) {
118
+			define('PS', PATH_SEPARATOR);
119
+		}
120
+		if ( ! defined('SP')) {
121
+			define('SP', ' ');
122
+		}
123
+		if ( ! defined('EENL')) {
124
+			define('EENL', "\n");
125
+		}
126
+		define('EE_SUPPORT_EMAIL', '[email protected]');
127
+		// define the plugin directory and URL
128
+		define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE));
129
+		define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE));
130
+		define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE));
131
+		// main root folder paths
132
+		define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS);
133
+		define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS);
134
+		define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS);
135
+		define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS);
136
+		define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS);
137
+		define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS);
138
+		define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS);
139
+		define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS);
140
+		// core system paths
141
+		define('EE_ADMIN', EE_CORE . 'admin' . DS);
142
+		define('EE_CPTS', EE_CORE . 'CPTs' . DS);
143
+		define('EE_CLASSES', EE_CORE . 'db_classes' . DS);
144
+		define('EE_INTERFACES', EE_CORE . 'interfaces' . DS);
145
+		define('EE_BUSINESS', EE_CORE . 'business' . DS);
146
+		define('EE_MODELS', EE_CORE . 'db_models' . DS);
147
+		define('EE_HELPERS', EE_CORE . 'helpers' . DS);
148
+		define('EE_LIBRARIES', EE_CORE . 'libraries' . DS);
149
+		define('EE_TEMPLATES', EE_CORE . 'templates' . DS);
150
+		define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS);
151
+		define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS);
152
+		define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS);
153
+		// gateways
154
+		define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS);
155
+		define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS);
156
+		// asset URL paths
157
+		define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS);
158
+		define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS);
159
+		define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS);
160
+		define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS);
161
+		define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/');
162
+		define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/');
163
+		// define upload paths
164
+		$uploads = wp_upload_dir();
165
+		// define the uploads directory and URL
166
+		define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS);
167
+		define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS);
168
+		// define the templates directory and URL
169
+		define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS);
170
+		define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS);
171
+		// define the gateway directory and URL
172
+		define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS);
173
+		define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS);
174
+		// languages folder/path
175
+		define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS);
176
+		define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS);
177
+		//check for dompdf fonts in uploads
178
+		if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) {
179
+			define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS);
180
+		}
181
+		//ajax constants
182
+		define(
183
+				'EE_FRONT_AJAX',
184
+				isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false
185
+		);
186
+		define(
187
+				'EE_ADMIN_AJAX',
188
+				isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false
189
+		);
190
+		//just a handy constant occasionally needed for finding values representing infinity in the DB
191
+		//you're better to use this than its straight value (currently -1) in case you ever
192
+		//want to change its default value! or find when -1 means infinity
193
+		define('EE_INF_IN_DB', -1);
194
+		define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX);
195
+		define('EE_DEBUG', false);
196
+		// for older WP versions
197
+		if ( ! defined('MONTH_IN_SECONDS')) {
198
+			define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30);
199
+		}
200
+		/**
201
+		 *    espresso_plugin_activation
202
+		 *    adds a wp-option to indicate that EE has been activated via the WP admin plugins page
203
+		 */
204
+		function espresso_plugin_activation()
205
+		{
206
+			update_option('ee_espresso_activation', true);
207
+		}
208 208
 
209
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
210
-        /**
211
-         *    espresso_load_error_handling
212
-         *    this function loads EE's class for handling exceptions and errors
213
-         */
214
-        function espresso_load_error_handling()
215
-        {
216
-            // load debugging tools
217
-            if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
218
-                require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php');
219
-                EEH_Debug_Tools::instance();
220
-            }
221
-            // load error handling
222
-            if (is_readable(EE_CORE . 'EE_Error.core.php')) {
223
-                require_once(EE_CORE . 'EE_Error.core.php');
224
-            } else {
225
-                wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
226
-            }
227
-        }
209
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
210
+		/**
211
+		 *    espresso_load_error_handling
212
+		 *    this function loads EE's class for handling exceptions and errors
213
+		 */
214
+		function espresso_load_error_handling()
215
+		{
216
+			// load debugging tools
217
+			if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
218
+				require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php');
219
+				EEH_Debug_Tools::instance();
220
+			}
221
+			// load error handling
222
+			if (is_readable(EE_CORE . 'EE_Error.core.php')) {
223
+				require_once(EE_CORE . 'EE_Error.core.php');
224
+			} else {
225
+				wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
226
+			}
227
+		}
228 228
 
229
-        /**
230
-         *    espresso_load_required
231
-         *    given a class name and path, this function will load that file or throw an exception
232
-         *
233
-         * @param    string $classname
234
-         * @param    string $full_path_to_file
235
-         * @throws    EE_Error
236
-         */
237
-        function espresso_load_required($classname, $full_path_to_file)
238
-        {
239
-            static $error_handling_loaded = false;
240
-            if ( ! $error_handling_loaded) {
241
-                espresso_load_error_handling();
242
-                $error_handling_loaded = true;
243
-            }
244
-            if (is_readable($full_path_to_file)) {
245
-                require_once($full_path_to_file);
246
-            } else {
247
-                throw new EE_Error (
248
-                        sprintf(
249
-                                esc_html__(
250
-                                        'The %s class file could not be located or is not readable due to file permissions.',
251
-                                        'event_espresso'
252
-                                ),
253
-                                $classname
254
-                        )
255
-                );
256
-            }
257
-        }
229
+		/**
230
+		 *    espresso_load_required
231
+		 *    given a class name and path, this function will load that file or throw an exception
232
+		 *
233
+		 * @param    string $classname
234
+		 * @param    string $full_path_to_file
235
+		 * @throws    EE_Error
236
+		 */
237
+		function espresso_load_required($classname, $full_path_to_file)
238
+		{
239
+			static $error_handling_loaded = false;
240
+			if ( ! $error_handling_loaded) {
241
+				espresso_load_error_handling();
242
+				$error_handling_loaded = true;
243
+			}
244
+			if (is_readable($full_path_to_file)) {
245
+				require_once($full_path_to_file);
246
+			} else {
247
+				throw new EE_Error (
248
+						sprintf(
249
+								esc_html__(
250
+										'The %s class file could not be located or is not readable due to file permissions.',
251
+										'event_espresso'
252
+								),
253
+								$classname
254
+						)
255
+				);
256
+			}
257
+		}
258 258
 
259
-        espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php');
260
-        espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php');
261
-        espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php');
262
-        new EE_Bootstrap();
263
-    }
259
+		espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php');
260
+		espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php');
261
+		espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php');
262
+		new EE_Bootstrap();
263
+	}
264 264
 }
265 265
 if ( ! function_exists('espresso_deactivate_plugin')) {
266
-    /**
267
-     *    deactivate_plugin
268
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
269
-     *
270
-     * @access public
271
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
272
-     * @return    void
273
-     */
274
-    function espresso_deactivate_plugin($plugin_basename = '')
275
-    {
276
-        if ( ! function_exists('deactivate_plugins')) {
277
-            require_once(ABSPATH . 'wp-admin/includes/plugin.php');
278
-        }
279
-        unset($_GET['activate'], $_REQUEST['activate']);
280
-        deactivate_plugins($plugin_basename);
281
-    }
266
+	/**
267
+	 *    deactivate_plugin
268
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
269
+	 *
270
+	 * @access public
271
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
272
+	 * @return    void
273
+	 */
274
+	function espresso_deactivate_plugin($plugin_basename = '')
275
+	{
276
+		if ( ! function_exists('deactivate_plugins')) {
277
+			require_once(ABSPATH . 'wp-admin/includes/plugin.php');
278
+		}
279
+		unset($_GET['activate'], $_REQUEST['activate']);
280
+		deactivate_plugins($plugin_basename);
281
+	}
282 282
 }
283 283
\ No newline at end of file
Please login to merge, or discard this patch.