Instapage WordPress Plugin - Version 3.3.0

Version Description

(2021-04-26) = - Ensure plugin core compatibility with PHP 8.0, - New toggle for selecting communication protocol when making a call to Instapage services (https/http), - Supports Instapage Experiment cookie's SameSite and Secure attributes - Increased Tested up to: 5.7.1

Download this release

Release Info

Developer marek@instapage.com
Plugin Icon 128x128 Instapage WordPress Plugin
Version 3.3.0
Comparing to
See all releases

Code changes from version 3.2.14 to 3.3.0

AjaxController.php DELETED
@@ -1,547 +0,0 @@
1
- <?php
2
- class AjaxController
3
- {
4
- private static $ajaxController = null;
5
-
6
- public static function getInstance()
7
- {
8
- if( self::$ajaxController === null )
9
- {
10
- self::$ajaxController = new AjaxController();
11
- }
12
-
13
- return self::$ajaxController;
14
- }
15
-
16
- public function doAction( $action, $data = null )
17
- {
18
- InstapageHelper::writeDiagnostics( $action, 'AJAX Action');
19
-
20
- if( !Connector::currentUserCanManage() )
21
- {
22
- echo InstapageHelper::formatJsonMessage( Connector::lang( 'You don\'t have permission to perform that action.' ), 'ERROR' );
23
- exit;
24
- }
25
-
26
- switch( $action )
27
- {
28
- case 'loginUser':
29
- $this->loginUser();
30
- break;
31
-
32
- case 'getApiTokens':
33
- $this->getApiTokens();
34
- break;
35
-
36
- case 'connectSubAccounts':
37
- $subaccount = SubaccountModel::getInstance();
38
- $subaccount->setSubAccountsStatus( 'connect' );
39
- break;
40
-
41
- case 'disconnectSubAccounts':
42
- $subaccount = SubaccountModel::getInstance();
43
- $subaccount->setSubAccountsStatus( 'disconnect' );
44
- break;
45
-
46
- case 'disconnectAccountBoundSubaccounts':
47
- $subaccount = SubaccountModel::getInstance();
48
- $subaccount->disconnectAccountBoundSubaccounts();
49
- break;
50
-
51
- case 'getAccountBoundSubAccounts':
52
- $subaccount = SubaccountModel::getInstance();
53
- $subaccount->getAccountBoundSubAccounts();
54
- break;
55
-
56
- case 'updateOptions':
57
- if( InstapageHelper::updateOptions( $data ) !== false )
58
- {
59
- echo InstapageHelper::formatJsonMessage( Connector::lang( 'Configuration updated' ), 'OK' );
60
- }
61
- else
62
- {
63
- echo InstapageHelper::formatJsonMessage( Connector::lang( 'There was an error during configuration save' ), 'ERROR' );
64
- }
65
- break;
66
-
67
- case 'getOptions':
68
- echo json_encode( InstapageHelper::getOptions() );
69
- break;
70
-
71
- case 'getLog':
72
- $this->getLog();
73
- break;
74
-
75
- case 'clearLog':
76
- $log = DebugLogModel::getInstance();
77
- $log->clear();
78
- echo InstapageHelper::formatJsonMessage( Connector::lang( 'Log cleared' ), 'OK' );
79
- break;
80
-
81
- case 'getMasterToken':
82
- $this->getMasterToken();
83
- break;
84
-
85
- case 'loadListPages':
86
- $this->loadListPages();
87
- break;
88
-
89
- case 'loadEditPage':
90
- $this->loadEditPage();
91
- break;
92
-
93
- case 'getLandingPages':
94
- $this->getLandingPages();
95
- break;
96
-
97
- case 'getStats':
98
- $this->getStats();
99
- break;
100
-
101
- case 'publishPage':
102
- $this->publishPage();
103
- break;
104
-
105
- case 'deletePage':
106
- $this->deletePage();
107
- break;
108
-
109
- case 'loadSettings':
110
- echo json_encode( (object) array(
111
- 'status' => 'OK',
112
- 'html' => InstapageHelper::loadTemplate( 'settings', false ),
113
- 'initialData' => InstapageHelper::getOptions()
114
- ) );
115
- break;
116
-
117
- case 'getProhibitedSlugs':
118
- $data = Connector::getSelectedConnector()->getProhibitedSlugs();
119
- echo json_encode( (object) array(
120
- 'status' => 'OK',
121
- 'data' => $data
122
- ) );
123
- break;
124
-
125
- case 'validateToken':
126
- $this->validateToken();
127
- break;
128
-
129
- case 'migrateDeprecatedData':
130
- $data = Connector::getSelectedConnector()->getDeprecatedData();
131
- $page = PageModel::getInstance();
132
- $raport = $page->migrateDeprecatedData( $data );
133
- $raport_str = implode( '<br />', $raport );
134
- echo InstapageHelper::formatJsonMessage( $raport_str );
135
- break;
136
-
137
- default:
138
- echo InstapageHelper::formatJsonMessage( Connector::lang( 'Unsupported AjaxController action' ), 'ERROR' );
139
- }
140
- }
141
-
142
- private function loginUser()
143
- {
144
- $api = APIModel::getInstance();
145
- $post = InstapageHelper::getPostData();
146
- $email = InstapageHelper::getVar( $post->data->email, '' );
147
- $password = InstapageHelper::getVar( $post->data->password, '' );
148
- $response = json_decode( $api->authorise( $email, $password ) );
149
-
150
- if( !InstapageHelper::checkResponse( $response, null, false ) || !$response->success )
151
- {
152
- $message = InstapageHelper::getVar( $response->message, '' );
153
- echo InstapageHelper::formatJsonMessage( $message, 'ERROR' );
154
- return false;
155
- }
156
- else
157
- {
158
- echo json_encode( (object) array(
159
- 'status' => 'OK',
160
- 'data' => (object) $response->data
161
- ) );
162
- }
163
- }
164
-
165
- private function validateToken()
166
- {
167
- $api = APIModel::getInstance();
168
- $post = InstapageHelper::getPostData();
169
- $token = InstapageHelper::getVar($post->data->token, null);
170
- $headers = array( 'accountkeys' => InstapageHelper::getAuthHeader( array( $token ) ) );
171
- $response = json_decode( $api->apiCall( 'page/get-sub-accounts-list', null, $headers ) );
172
- $sub_account = @InstapageHelper::getVar( $response->data, null );
173
-
174
- if( !InstapageHelper::checkResponse( $response, null, false) || !$response->success || count( $sub_account ) == 0 )
175
- {
176
- echo json_encode( (object) array(
177
- 'status' => 'OK',
178
- 'valid' => false
179
- ) );
180
- }
181
- else
182
- {
183
- echo json_encode( (object) array(
184
- 'status' => 'OK',
185
- 'valid' => true
186
- ) );
187
- }
188
- }
189
-
190
- private function getLog()
191
- {
192
- $log = DebugLogModel::getInstance();
193
- $sitename_sanitized = Connector::getSitename( true ) ;
194
- try
195
- {
196
- $data = $log->getLogHTML();
197
- echo json_encode( (object) array(
198
- 'status' => 'OK',
199
- 'data' => $data,
200
- 'sitename' => $sitename_sanitized
201
- ) );
202
- }
203
- catch( Exception $e )
204
- {
205
- echo InstapageHelper::formatJsonMessage( $e->getMessage(), 'ERROR' );
206
- }
207
- }
208
-
209
- private function getApiTokens()
210
- {
211
- $subaccount = SubaccountModel::getInstance();
212
- $tokens = $subaccount->getAllTokens();
213
- echo json_encode( (object) array(
214
- 'status' => 'OK',
215
- 'data' => $tokens
216
- ) );
217
- }
218
-
219
- private function loadEditPage()
220
- {
221
- $api = APIModel::getInstance();
222
- $subaccount = SubaccountModel::getInstance();
223
- $post = InstapageHelper::getPostData();
224
- InstapageHelper::writeDiagnostics( $post, 'Edit page POST');
225
- $tokens = InstapageHelper::getVar( $post->apiTokens, false );
226
-
227
- if( !$tokens )
228
- {
229
- $tokens = $subaccount->getAllTokens();
230
- }
231
-
232
- $page_data = null;
233
- $sub_accounts = null;
234
- $data = array();
235
-
236
- if( isset( $post->data->id ) )
237
- {
238
- $page_data = $post->data;
239
- $data[ 'pages' ] = array( $post->data->instapage_id );
240
-
241
- }
242
-
243
- $headers = array( 'accountkeys' => InstapageHelper::getAuthHeader( $tokens ) );
244
- $response = json_decode( $api->apiCall( 'page/get-sub-accounts-list', $data, $headers ) );
245
-
246
- if( InstapageHelper::checkResponse( $response ) )
247
- {
248
- $sub_accounts = $response->data;
249
- }
250
- else
251
- {
252
- return false;
253
- }
254
-
255
- $initialData = array( 'subAccounts' => $sub_accounts, 'page' => $page_data );
256
- InstapageHelper::writeDiagnostics( $initialData, 'Edit page initialData');
257
-
258
- echo json_encode( (object) array(
259
- 'status' => 'OK',
260
- 'html' => InstapageHelper::loadTemplate( 'edit', false ),
261
- 'data' => (object) $initialData
262
- ) );
263
- }
264
-
265
- private function loadListPages()
266
- {
267
- $request_limit = 300;
268
- $post = InstapageHelper::getPostData();
269
- $page = PageModel::getInstance();
270
- InstapageHelper::writeDiagnostics( $post, 'List page POST');
271
- $api = APIModel::getInstance();
272
- $subaccount = SubaccountModel::getInstance();
273
- $local_pages_array = $page->getAll( array( 'id', 'instapage_id', 'slug', 'type', 'stats_cache', 'enterprise_url' ) );
274
-
275
- //WP Legacy code - automatic migration
276
- $automatic_migration = InstapageHelper::getMetadata( 'automatic_migration', false );
277
-
278
- if( empty( $automatic_migration ) && !count( $local_pages_array ) && Connector::isWP() && Connector::getSelectedConnector()->legacyArePagesPresent() )
279
- {
280
- $data = Connector::getSelectedConnector()->getDeprecatedData();
281
- $page = PageModel::getInstance();
282
- $page->migrateDeprecatedData( $data );
283
- $local_pages_array = $page->getAll( array( 'id', 'instapage_id', 'slug', 'type', 'stats_cache', 'enterprise_url' ) );
284
- InstapageHelper::updateMetadata( 'automatic_migration', time() );
285
- }
286
-
287
- $pages = array();
288
-
289
- foreach( $local_pages_array as &$page_object )
290
- {
291
- $page_object->stats_cache = json_decode($page_object->stats_cache);
292
- $pages[] = $page_object->instapage_id;
293
- }
294
-
295
- $tokens = InstapageHelper::getVar( $post->apiTokens, false );
296
-
297
- if( !$tokens )
298
- {
299
- $tokens = $subaccount->getAllTokens();
300
- }
301
-
302
- if( !count( $tokens ) )
303
- {
304
- echo json_encode( (object) array(
305
- 'status' => 'OK',
306
- 'html' => InstapageHelper::loadTemplate( 'listing', false ),
307
- 'initialData' => $local_pages_array
308
- ) );
309
-
310
- return true;
311
- }
312
-
313
-
314
- $headers = array( 'accountkeys' => InstapageHelper::getAuthHeader( $tokens ) );
315
- $responses = array();
316
- $success = true;
317
-
318
- for( $i = 0; $i * $request_limit < count( $pages ); ++$i )
319
- {
320
- $data_slice = array_slice( $pages, $i * $request_limit, $request_limit );
321
- $data = array( 'pages' => $data_slice );
322
- $response_json = $api->apiCall( 'page/list', $data, $headers, 'GET' );
323
- $response = json_decode( $response_json );
324
-
325
- if( InstapageHelper::checkResponse( $response ) )
326
- {
327
- $responses[] = $response->data;
328
- }
329
- else
330
- {
331
- $success = false;
332
- break;
333
- }
334
- }
335
-
336
- if( $success )
337
- {
338
- $merged_response = array();
339
-
340
- foreach( $responses as $r )
341
- {
342
- $merged_response = array_merge( $merged_response, $r );
343
- }
344
-
345
- $page->mergeListPagesResults( $local_pages_array, $merged_response );
346
- InstapageHelper::writeDiagnostics( $local_pages_array, 'List page array');
347
- echo json_encode( (object) array(
348
- 'status' => 'OK',
349
- 'html' => InstapageHelper::loadTemplate( 'listing', false ),
350
- 'initialData' => $local_pages_array
351
- ) );
352
- }
353
- else
354
- {
355
- return false;
356
- }
357
- }
358
-
359
- private function getLandingPages()
360
- {
361
- $api = APIModel::getInstance();
362
- $post = InstapageHelper::getPostData();
363
- $tokens = array( $post->data->subAccountToken );
364
- $headers = array( 'accountkeys' => InstapageHelper::getAuthHeader( $tokens ) );
365
- $response_json = $api->apiCall( 'page/list', null, $headers );
366
- $response =json_decode( $response_json );
367
- $page = PageModel::getInstance();
368
- $published_pages = $page->getAll( array( 'instapage_id' ) );
369
- $self_instapage_id = @InstapageHelper::getVar( $post->data->selfInstapageId, null );
370
-
371
- if( InstapageHelper::checkResponse( $response ) )
372
- {
373
- if( is_array( $response->data ) )
374
- {
375
- foreach( $response->data as $key => $returned_page )
376
- {
377
- foreach( $published_pages as $published_page )
378
- {
379
- if( $returned_page->id != $self_instapage_id && $returned_page->id == $published_page->instapage_id )
380
- {
381
- unset( $response->data[ $key ] );
382
- break;
383
- }
384
- }
385
- }
386
-
387
- $response->data = array_values( $response->data );
388
- }
389
- else
390
- {
391
- $response->data = array();
392
- }
393
-
394
- echo json_encode( (object) array(
395
- 'status' => 'OK',
396
- 'data' => $response->data
397
- ) );
398
- }
399
- else
400
- {
401
- return false;
402
- }
403
- }
404
-
405
- private function getStats()
406
- {
407
- $post = InstapageHelper::getPostData();
408
- $page = PageModel::getInstance();
409
- $api = APIModel::getInstance();
410
- $subaccount = SubaccountModel::getInstance();
411
- $pages = InstapageHelper::getVar( $post->data->pages, array() );
412
-
413
- if( !count( $pages ) )
414
- {
415
- InstapageHelper::writeDiagnostics( 'Stats cond', 'No pages in request' );
416
- echo json_encode( (object) array(
417
- 'status' => 'OK',
418
- 'data' => array()
419
- ) );
420
-
421
- return true;
422
- }
423
-
424
- $cached_stats = $page->getPageStatsCache( $pages );
425
- InstapageHelper::writeDiagnostics( $cached_stats, 'Cached stats');
426
- $pages_without_stats = array();
427
-
428
- foreach( $pages as $instapage_id )
429
- {
430
- if( !isset( $cached_stats[ $instapage_id ] ) )
431
- {
432
- $pages_without_stats[] = $instapage_id;
433
- }
434
- }
435
-
436
- if( empty( $pages_without_stats ) )
437
- {
438
- echo json_encode( (object) array(
439
- 'status' => 'OK',
440
- 'data' => $cached_stats
441
- ) );
442
-
443
- return true;
444
- }
445
-
446
- $tokens = InstapageHelper::getVar( $post->apiTokens, false );
447
-
448
- if( !$tokens )
449
- {
450
- $tokens = $subaccount->getAllTokens();
451
- }
452
-
453
- $headers = array( 'accountkeys' => InstapageHelper::getAuthHeader( $tokens ) );
454
- $data = array( 'pages' => $pages_without_stats );
455
- $response_json = $api->apiCall( 'page/stats', $data, $headers );
456
- $response =json_decode( $response_json );
457
-
458
- if( InstapageHelper::checkResponse( $response ) )
459
- {
460
- $stats = (array) InstapageHelper::getVar( $response->data, array() );
461
- $page->savePageStatsCache( $stats );
462
-
463
- if( count( $stats ) )
464
- {
465
- $stats = array_merge( $cached_stats, $stats );
466
- }
467
- else
468
- {
469
- $stats = $cached_stats;
470
- }
471
-
472
- echo json_encode( (object) array(
473
- 'status' => 'OK',
474
- 'data' => $stats
475
- ) );
476
- }
477
- else
478
- {
479
- return false;
480
- }
481
- }
482
-
483
- private function publishPage()
484
- {
485
- $page = PageModel::getInstance();
486
- $post = InstapageHelper::getPostData();
487
- $data = $post->data;
488
-
489
- echo $page->publishPage( $data );
490
- }
491
-
492
- private function deletePage()
493
- {
494
- $page = PageModel::getInstance();
495
- $api = APIModel::getInstance();
496
- $subaccount = SubaccountModel::getInstance();
497
- $post = InstapageHelper::getPostData();
498
- $result = $page->get( $post->data->id, array( 'instapage_id' ) );
499
- $instapage_id = $result->instapage_id;
500
- $tokens = InstapageHelper::getVar( $post->apiTokens, false );
501
-
502
- if( !$tokens )
503
- {
504
- $tokens = $subaccount->getAllTokens();
505
- }
506
-
507
- $data = array(
508
- 'page' => $instapage_id,
509
- 'url' => '',
510
- 'publish' => 0
511
- );
512
- $headers = array( 'accountkeys' => InstapageHelper::getAuthHeader( $tokens ) );
513
- $response = json_decode( $api->apiCall( 'page/edit', $data, $headers ) );
514
-
515
- $message = '';
516
-
517
- if( !InstapageHelper::checkResponse( $response, null, false) || !$response->success )
518
- {
519
- $message .= Connector::lang( 'Page that you are removing (Instapage ID: %s) doesn\'t exist in your Instapage application\'s dashboard. It could have been deleted from app or created by another user. Deleting this page won\'t affect Instapage application\'s dashboard.', $instapage_id );
520
-
521
- if( isset( $response->message ) && $response->message !== '' )
522
- {
523
- $message .= Connector::lang( ' Instapage app response: ' . $response->message );
524
- }
525
- }
526
-
527
- if( isset( $post->data->id ) && $page->delete( $post->data->id ) )
528
- {
529
- if( $message )
530
- {
531
- echo InstapageHelper::formatJsonMessage( $message );
532
- }
533
- else
534
- {
535
- echo InstapageHelper::formatJsonMessage( Connector::lang( 'Page deleted successfully.' ) );
536
- }
537
-
538
- return true;
539
- }
540
- else
541
- {
542
- echo InstapageHelper::formatJsonMessage( Connector::lang( 'There was a database error during page delete process.' ), 'ERROR' );
543
-
544
- return false;
545
- }
546
- }
547
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
InstapageCmsPluginAjaxController.php CHANGED
@@ -165,12 +165,12 @@ class InstapageCmsPluginAjaxController {
165
  private function loginUser() {
166
  $api = InstapageCmsPluginAPIModel::getInstance();
167
  $post = InstapageCmsPluginHelper::getPostData();
168
- $email = urldecode(InstapageCmsPluginHelper::getVar($post->data->email, ''));
169
- $password = urldecode(InstapageCmsPluginHelper::getVar($post->data->password, ''));
170
  $response = json_decode($api->authorise($email, $password));
171
 
172
  if (!InstapageCmsPluginHelper::checkResponse($response, null, false) || !$response->success) {
173
- $message = InstapageCmsPluginHelper::getVar($response->message, '');
174
  echo InstapageCmsPluginHelper::formatJsonMessage($message, 'ERROR');
175
 
176
  return false;
@@ -188,10 +188,10 @@ class InstapageCmsPluginAjaxController {
188
  private function validateToken() {
189
  $api = InstapageCmsPluginAPIModel::getInstance();
190
  $post = InstapageCmsPluginHelper::getPostData();
191
- $token = InstapageCmsPluginHelper::getVar($post->data->token, null);
192
  $headers = array('accountkeys' => InstapageCmsPluginHelper::getAuthHeader(array($token)));
193
  $response = json_decode($api->apiCall('page/get-sub-accounts-list', null, $headers));
194
- $subAccount = @InstapageCmsPluginHelper::getVar($response->data, null);
195
 
196
  if (!InstapageCmsPluginHelper::checkResponse($response, null, false) || !$response->success || count($subAccount) == 0) {
197
  echo json_encode((object) array(
@@ -246,7 +246,7 @@ class InstapageCmsPluginAjaxController {
246
  $subaccount = InstapageCmsPluginSubaccountModel::getInstance();
247
  $post = InstapageCmsPluginHelper::getPostData();
248
  InstapageCmsPluginHelper::writeDiagnostics($post, 'Edit page POST');
249
- $tokens = InstapageCmsPluginHelper::getVar($post->apiTokens, false);
250
 
251
  if (!$tokens) {
252
  $tokens = $subaccount->getAllTokens();
@@ -310,7 +310,7 @@ class InstapageCmsPluginAjaxController {
310
  $pages[] = $pageObject->instapage_id;
311
  }
312
 
313
- $tokens = InstapageCmsPluginHelper::getVar($post->apiTokens, false);
314
 
315
  if (!$tokens) {
316
  $tokens = $subaccount->getAllTokens();
@@ -370,7 +370,7 @@ class InstapageCmsPluginAjaxController {
370
  $response = json_decode($responseJson);
371
  $page = InstapageCmsPluginPageModel::getInstance();
372
  $publishedPages = $page->getAll(array('instapage_id'));
373
- $selfInstapageId = @InstapageCmsPluginHelper::getVar($post->data->selfInstapageId, null);
374
 
375
  if (InstapageCmsPluginHelper::checkResponse($response)) {
376
  if (is_array($response->data)) {
@@ -405,7 +405,7 @@ class InstapageCmsPluginAjaxController {
405
  $page = InstapageCmsPluginPageModel::getInstance();
406
  $api = InstapageCmsPluginAPIModel::getInstance();
407
  $subaccount = InstapageCmsPluginSubaccountModel::getInstance();
408
- $pages = InstapageCmsPluginHelper::getVar($post->data->pages, array());
409
 
410
  if (!count($pages)) {
411
  InstapageCmsPluginHelper::writeDiagnostics('Stats cond', 'No pages in request');
@@ -436,7 +436,7 @@ class InstapageCmsPluginAjaxController {
436
  return true;
437
  }
438
 
439
- $tokens = InstapageCmsPluginHelper::getVar($post->apiTokens, false);
440
 
441
  if (!$tokens) {
442
  $tokens = $subaccount->getAllTokens();
@@ -448,7 +448,7 @@ class InstapageCmsPluginAjaxController {
448
  $response = json_decode($responseJson);
449
 
450
  if (InstapageCmsPluginHelper::checkResponse($response)) {
451
- $stats = (array) InstapageCmsPluginHelper::getVar($response->data, array());
452
  $page->savePageStatsCache($stats);
453
 
454
  if (count($stats)) {
@@ -487,7 +487,7 @@ class InstapageCmsPluginAjaxController {
487
  $post = InstapageCmsPluginHelper::getPostData();
488
  $result = $page->get($post->data->id, array('instapage_id'));
489
  $instapageId = $result->instapage_id;
490
- $tokens = InstapageCmsPluginHelper::getVar($post->apiTokens, false);
491
 
492
  if (!$tokens) {
493
  $tokens = $subaccount->getAllTokens();
165
  private function loginUser() {
166
  $api = InstapageCmsPluginAPIModel::getInstance();
167
  $post = InstapageCmsPluginHelper::getPostData();
168
+ $email = urldecode(isset($post->data->email) ? $post->data->email : '');
169
+ $password = urldecode(isset($post->data->password) ? $post->data->password : '');
170
  $response = json_decode($api->authorise($email, $password));
171
 
172
  if (!InstapageCmsPluginHelper::checkResponse($response, null, false) || !$response->success) {
173
+ $message = isset($response->message) ? $response->message : '';
174
  echo InstapageCmsPluginHelper::formatJsonMessage($message, 'ERROR');
175
 
176
  return false;
188
  private function validateToken() {
189
  $api = InstapageCmsPluginAPIModel::getInstance();
190
  $post = InstapageCmsPluginHelper::getPostData();
191
+ $token = isset($post->data->token) ? $post->data->token : null;
192
  $headers = array('accountkeys' => InstapageCmsPluginHelper::getAuthHeader(array($token)));
193
  $response = json_decode($api->apiCall('page/get-sub-accounts-list', null, $headers));
194
+ $subAccount = isset($response->data) ? $response->data : null;
195
 
196
  if (!InstapageCmsPluginHelper::checkResponse($response, null, false) || !$response->success || count($subAccount) == 0) {
197
  echo json_encode((object) array(
246
  $subaccount = InstapageCmsPluginSubaccountModel::getInstance();
247
  $post = InstapageCmsPluginHelper::getPostData();
248
  InstapageCmsPluginHelper::writeDiagnostics($post, 'Edit page POST');
249
+ $tokens = isset($post->apiTokens) ? $post->apiTokens : false;
250
 
251
  if (!$tokens) {
252
  $tokens = $subaccount->getAllTokens();
310
  $pages[] = $pageObject->instapage_id;
311
  }
312
 
313
+ $tokens = isset($post->apiTokens) ? $post->apiTokens : false;
314
 
315
  if (!$tokens) {
316
  $tokens = $subaccount->getAllTokens();
370
  $response = json_decode($responseJson);
371
  $page = InstapageCmsPluginPageModel::getInstance();
372
  $publishedPages = $page->getAll(array('instapage_id'));
373
+ $selfInstapageId = isset($post->data->selfInstapageId) ? $post->data->selfInstapageId : null;
374
 
375
  if (InstapageCmsPluginHelper::checkResponse($response)) {
376
  if (is_array($response->data)) {
405
  $page = InstapageCmsPluginPageModel::getInstance();
406
  $api = InstapageCmsPluginAPIModel::getInstance();
407
  $subaccount = InstapageCmsPluginSubaccountModel::getInstance();
408
+ $pages = isset($post->data->pages) ? $post->data->pages : array();
409
 
410
  if (!count($pages)) {
411
  InstapageCmsPluginHelper::writeDiagnostics('Stats cond', 'No pages in request');
436
  return true;
437
  }
438
 
439
+ $tokens = isset($post->apiTokens) ? $post->apiTokens : false;
440
 
441
  if (!$tokens) {
442
  $tokens = $subaccount->getAllTokens();
448
  $response = json_decode($responseJson);
449
 
450
  if (InstapageCmsPluginHelper::checkResponse($response)) {
451
+ $stats = (array)(isset($response->data) ? $response->data : array());
452
  $page->savePageStatsCache($stats);
453
 
454
  if (count($stats)) {
487
  $post = InstapageCmsPluginHelper::getPostData();
488
  $result = $page->get($post->data->id, array('instapage_id'));
489
  $instapageId = $result->instapage_id;
490
+ $tokens = isset($post->apiTokens) ? $post->apiTokens : false;
491
 
492
  if (!$tokens) {
493
  $tokens = $subaccount->getAllTokens();
InstapageCmsPluginHelper.php CHANGED
@@ -109,9 +109,9 @@ class InstapageCmsPluginHelper {
109
  $options = self::getOptions();
110
 
111
  if (in_array($name, array('plugin_hash', 'user_name', 'api_keys'))) {
112
- return self::getVar($options->$name, $default);
113
  } else {
114
- return self::getVar($options->config->$name, $default);
115
  }
116
  }
117
 
@@ -125,15 +125,15 @@ class InstapageCmsPluginHelper {
125
  * @return mixed Query result of false on query of false on query error. Exception message is logged in standard error log.
126
  */
127
  public static function updateOptions($data) {
128
- $userName = @self::getVar($data->userName, null);
129
- $userToken = @self::getVar($data->userToken, null);
130
 
131
  if ($userName === null) {
132
- $userName = @self::getVar($data->user_name, null);
133
  }
134
 
135
  if ($userToken === null) {
136
- $userToken = @self::getVar($data->plugin_hash, null);
137
  }
138
 
139
  $configJson = !empty($data->config) ? json_encode($data->config) : '';
@@ -205,18 +205,6 @@ class InstapageCmsPluginHelper {
205
  return $tokens;
206
  }
207
 
208
- /**
209
- * Returns the given variable if it's set, or default value otherwise.
210
- *
211
- * @param mixed $value. Value to be checked.
212
- * @param mixed $default. Default value. Default: false.
213
- *
214
- * @return mxed if value is set, returns the value. In other case returns default value or false.
215
- */
216
- public static function getVar(&$value, $default = false) {
217
- return isset($value) ? $value : $default;
218
- }
219
-
220
  /**
221
  * Checks if one of the custom params, stored in plugin's settings, are present in curent URL.
222
  *
@@ -276,8 +264,8 @@ class InstapageCmsPluginHelper {
276
 
277
  /**
278
  * Check if request uri has duplicated slashes.
279
- *
280
- * @return boolean True if requested uri has duplicated slashes, false if uri is ok
281
  */
282
  public static function checkIfRequestUriHasDuplicatedSlashes() {
283
  $url = $_SERVER['REQUEST_URI'];
@@ -364,7 +352,7 @@ class InstapageCmsPluginHelper {
364
  }
365
 
366
  if (!$response->success) {
367
- $text = @self::getVar($response->message, '');
368
 
369
  if ($print) {
370
  if ($text) {
109
  $options = self::getOptions();
110
 
111
  if (in_array($name, array('plugin_hash', 'user_name', 'api_keys'))) {
112
+ return isset($options->$name) ? $options->$name : $default;
113
  } else {
114
+ return isset($options->config->$name) ? $options->config->$name : $default;
115
  }
116
  }
117
 
125
  * @return mixed Query result of false on query of false on query error. Exception message is logged in standard error log.
126
  */
127
  public static function updateOptions($data) {
128
+ $userName = isset($data->userName) ? $data->userName : null;
129
+ $userToken = isset($data->userToken) ? $data->userToken : null;
130
 
131
  if ($userName === null) {
132
+ $userName = isset($data->user_name) ? $data->user_name : null;
133
  }
134
 
135
  if ($userToken === null) {
136
+ $userToken = isset($data->plugin_hash) ? $data->plugin_hash : null;
137
  }
138
 
139
  $configJson = !empty($data->config) ? json_encode($data->config) : '';
205
  return $tokens;
206
  }
207
 
 
 
 
 
 
 
 
 
 
 
 
 
208
  /**
209
  * Checks if one of the custom params, stored in plugin's settings, are present in curent URL.
210
  *
264
 
265
  /**
266
  * Check if request uri has duplicated slashes.
267
+ *
268
+ * @return boolean True if requested uri has duplicated slashes, false if uri is ok
269
  */
270
  public static function checkIfRequestUriHasDuplicatedSlashes() {
271
  $url = $_SERVER['REQUEST_URI'];
352
  }
353
 
354
  if (!$response->success) {
355
+ $text = isset($response->message) ? $response->message : '';
356
 
357
  if ($print) {
358
  if ($text) {
InstapageHelper.php DELETED
@@ -1,392 +0,0 @@
1
- <?php
2
- class InstapageHelper
3
- {
4
- public static function loadTemplate( $tmpl, $print = true )
5
- {
6
- $template_file = INSTAPAGE_PLUGIN_PATH . '/views/' . $tmpl . '.php';
7
-
8
- if( file_exists( $template_file ) )
9
- {
10
- if( !$print )
11
- {
12
- ob_start();
13
- }
14
-
15
- require( $template_file );
16
-
17
- if( !$print )
18
- {
19
- $contents = ob_get_contents();
20
- ob_end_clean();
21
-
22
- return $contents;
23
- }
24
- }
25
- else
26
- {
27
- throw new Exception( Connector::lang( 'Template file (%s) not found', $template_file ) );
28
- }
29
- }
30
-
31
- public static function initMessagesSystem()
32
- {
33
- self::loadTemplate( 'messages' );
34
- }
35
-
36
- public static function getMenuIcon()
37
- {
38
- return 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz48IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB3aWR0aD0iMTUiIGhlaWdodD0iMTUuOTY5IiB2aWV3Qm94PSIwIDAgMTUgMTUuOTY5Ij4NCiAgPGRlZnM+DQogICAgPHN0eWxlPg0KICAgICAgLmNscy0xIHsNCiAgICAgICAgZmlsbDogI2ZmZjsNCiAgICAgICAgZmlsbC1ydWxlOiBldmVub2RkOw0KICAgICAgfQ0KICAgIDwvc3R5bGU+DQogIDwvZGVmcz4NCiAgPHBhdGggaWQ9Il8xNi1sb2dvLnN2ZyIgZGF0YS1uYW1lPSIxNi1sb2dvLnN2ZyIgY2xhc3M9ImNscy0xIiBkPSJNMTIuMDEyLDkuMzE4YTAuODM5LDAuODM5LDAsMCwwLS45NTguODVWMjEuNjk0YTAuODM4LDAuODM4LDAsMCwwLC45ODcuODQ1bDAuMDkxLS4wMTlWOS4zMzdaTTkuOTU3LDEwLjU5M0EwLjgzOSwwLjgzOSwwLDAsMCw5LDExLjQ0M3Y5YTAuODM3LDAuODM3LDAsMCwwLC45ODcuODQ1bDAuMDkxLS4wMThWMTAuNjEyWk0yMy4yNjMsOS41MTNsLTkuMDgyLTEuNWEwLjg4OCwwLjg4OCwwLDAsMC0xLjAxNC45VjIzLjA4N2EwLjg4NywwLjg4NywwLDAsMCwxLjA0NC44OTRsOS4wODEtMS42OTRBMC45LDAuOSwwLDAsMCwyNCwyMS4zOTRWMTAuNDEzYTAuOSwwLjksMCwwLDAtLjczOC0wLjlNMjIuNDc2LDIwLjNhMC42NzcsMC42NzcsMCwwLDEtLjUuNjc5bC01Ljk1NiwxYTAuNjQyLDAuNjQyLDAsMCwxLS43MzctMC42NzlWMTAuNzM5QTAuNjQ1LDAuNjQ1LDAsMCwxLDE2LDEwLjA1NWw1Ljk1NiwwLjc4OWEwLjY3NCwwLjY3NCwwLDAsMSwuNTIxLjY4NFYyMC4zWiIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoLTkgLTgpIi8+DQo8L3N2Zz4=';
39
- }
40
-
41
- public static function initAjaxURL()
42
- {
43
- echo '<script>var INSTAPAGE_AJAXURL = \'' . Connector::getAjaxURL() . '\';</script>';
44
- }
45
-
46
- public static function getOptions( $configOnly = false )
47
- {
48
- $db = DBModel::getInstance();
49
-
50
- if( $configOnly )
51
- {
52
- $sql = 'SELECT config FROM ' . $db->optionsTable;
53
- $row = $db->getRow( $sql );
54
-
55
- if( isset( $row->config ) )
56
- {
57
- return json_decode( $row->config );
58
- }
59
-
60
- return new stdClass;
61
- }
62
- else
63
- {
64
- $sql = 'SELECT * FROM ' . $db->optionsTable;
65
- $options = $db->getRow( $sql );
66
-
67
- if( $options === false )
68
- {
69
- return new stdClass;
70
- }
71
-
72
- if( isset( $options->config ) )
73
- {
74
- $options->config = json_decode( $options->config );
75
- }
76
-
77
- return $options;
78
- }
79
- }
80
-
81
- public static function getOption( $name, $default = false )
82
- {
83
- $options = self::getOptions();
84
-
85
- if( in_array( $name, array( 'plugin_hash', 'user_name', 'api_keys' ) ) )
86
- {
87
- return self::getVar( $options->$name, $default );
88
- }
89
- else
90
- {
91
- return self::getVar( $options->config->$name, $default );
92
- }
93
- }
94
-
95
- public static function updateOptions( $data )
96
- {
97
- $userName = @InstapageHelper::getVar( $data->userName, null );
98
- $userToken = @InstapageHelper::getVar( $data->userToken, null );
99
-
100
- if( $userName === null )
101
- {
102
- $userName = @InstapageHelper::getVar( $data->user_name, null );
103
- }
104
-
105
- if( $userToken === null )
106
- {
107
- $userToken = @InstapageHelper::getVar( $data->plugin_hash, null );
108
- }
109
-
110
- $configJson = !empty( $data->config ) ? json_encode( $data->config ) : '';
111
- $metadataJson = !empty( $data->metadata ) ? json_encode( $data->metadata ) : '';
112
- $db = DBModel::getInstance();
113
- $sql = 'INSERT INTO ' . $db->optionsTable . '(id, plugin_hash, api_keys, user_name, config, metadata) VALUES(1, %s, %s, %s, %s, %s) ON DUPLICATE KEY UPDATE plugin_hash = %s, api_keys = %s, user_name = %s, config = %s, metadata=%s';
114
-
115
- return $db->query( $sql, $userToken, '', $userName, $configJson, $metadataJson, $userToken, '', $userName, $configJson, $metadataJson );
116
- }
117
-
118
- public static function updateMetadata( $key, $value )
119
- {
120
- $metadata = self::getMetadata();
121
- $metadata[ $key ] = $value;
122
- $db = DBModel::getInstance();
123
- $sql = 'INSERT INTO ' . $db->optionsTable. '(id, metadata) VALUES(1, %s) ON DUPLICATE KEY UPDATE metadata = %s';
124
- $metadata_json = !empty( $metadata ) ? json_encode( $metadata ) : '';
125
-
126
- return $db->query( $sql, $metadata_json, $metadata_json );
127
- }
128
-
129
- public static function getMetadata( $key = '', $default = null )
130
- {
131
- $db = DBModel::getInstance();
132
- $sql = 'SELECT metadata FROM ' . $db->optionsTable;
133
- $row = $db->getRow( $sql );
134
- $metadata = array();
135
-
136
- if( isset( $row->metadata ) && $row->metadata )
137
- {
138
- $metadata = (array) json_decode( $row->metadata );
139
- }
140
-
141
- if( !empty( $key ) )
142
- {
143
- return isset( $metadata[ $key ] ) ? $metadata[ $key ] : $default;
144
- }
145
-
146
- return $metadata;
147
- }
148
-
149
- public static function getTokens()
150
- {
151
- $config = self::getOptions( true );
152
- $tokens = array();
153
-
154
- if( !isset( $config->tokens ) || !is_array( $config->tokens ) )
155
- {
156
- return array();
157
- }
158
-
159
- foreach( $config->tokens as $token )
160
- {
161
- $tokens[] = $token->value;
162
- }
163
-
164
- return $tokens;
165
- }
166
-
167
- public static function getVar( &$value, $default = false )
168
- {
169
- return isset( $value ) ? $value : $default;
170
- }
171
-
172
- public static function isCustomParamPresent()
173
- {
174
- $slug = self::extractSlug( Connector::getHomeUrl() );
175
- $default_excluded_params = array
176
- (
177
- 's' => null,
178
- 'post_type' => null,
179
- 'preview' => 'true'
180
- );
181
-
182
- $custom_params_option = explode( '|', stripslashes( self::getOption( 'customParams', '' ) ) );
183
- $custom_params = array();
184
- $param_arr = null;
185
- $key = null;
186
- $value = null;
187
-
188
- foreach( $custom_params_option as $param )
189
- {
190
- $param_arr = explode( '=', $param );
191
- $key = isset( $param_arr[ 0 ] ) ? $param_arr[ 0 ] : null;
192
- $value = isset( $param_arr[ 1 ] ) ? str_replace( '"', '', $param_arr[ 1 ] ) : null;
193
- $custom_params[ $key ] = $value;
194
- }
195
-
196
- if( count( $custom_params ) )
197
- {
198
- $excluded_params = array_merge( $default_excluded_params, $custom_params );
199
- }
200
-
201
- foreach( $excluded_params as $key => $value )
202
- {
203
- $is_default_param = array_key_exists( $key, $default_excluded_params ) ? true : false;
204
-
205
- if(
206
- ( !empty( $key ) && $value == null && ( isset( $_GET[ $key ] ) || ( !$is_default_param && strpos( $slug, $key ) !== false ) ) ) ||
207
- ( !empty( $key ) && $value !== null && isset( $_GET[ $key ] ) && $_GET[ $key ] == $value )
208
- )
209
- {
210
- return true;
211
- }
212
- }
213
-
214
- return false;
215
- }
216
-
217
- public static function prepareUrlForUpdate( $url )
218
- {
219
- return trim( str_replace( array( 'http://', 'https://' ), '', $url ), '/' );
220
- }
221
-
222
- public static function extractSlug( $home_url )
223
- {
224
- $uri_segments = explode( '?', $_SERVER[ 'REQUEST_URI' ] );
225
- self::writeDiagnostics( $uri_segments, 'checkCustomUrl: $uri_segments' );
226
- $path = trim( parse_url( $home_url, PHP_URL_PATH ), '/' );
227
- $segment = trim( $uri_segments[ 0 ], '/' );
228
-
229
- if( $path )
230
- {
231
- $pos = strpos( $segment, $path );
232
-
233
- if( $pos !== false )
234
- {
235
- $segment = substr_replace( $segment, '', $pos, strlen( $path ) );
236
- }
237
- }
238
-
239
- $slug = trim( $segment, '/' );
240
- self::writeDiagnostics( $slug, 'checkCustomUrl: $slug' );
241
-
242
- return $slug;
243
- }
244
-
245
- public static function getPostData()
246
- {
247
- return isset( $_POST[ 'data' ] ) ? json_decode( urldecode( $_POST[ 'data' ] ) ) : null;
248
- }
249
-
250
- public static function formatJsonMessage( $text, $status = 'OK' )
251
- {
252
- self::writeDiagnostics( $text, 'Message' );
253
-
254
- return json_encode( (object) array( 'status' => $status, 'message' => $text ) );
255
- }
256
-
257
- public static function checkResponse( $response, $message = '', $print = true )
258
- {
259
- if( is_null( $response ) )
260
- {
261
- $msgText = Connector::lang( 'Can\'t decode API response. %s', $message );
262
- if( $print )
263
- {
264
- echo self::formatJsonMessage( $msgText, 'ERROR' );
265
- }
266
- else
267
- {
268
- InstapageHelper::writeDiagnostics( $msgText, 'message' );
269
- }
270
-
271
- return false;
272
- }
273
-
274
- if( !$response->success )
275
- {
276
- $text = @self::getVar( $response->message, '' );
277
-
278
- if( $print )
279
- {
280
- if( $text )
281
- {
282
- echo self::formatJsonMessage( Connector::lang( $text ), 'ERROR' );
283
- }
284
- else
285
- {
286
- echo self::formatJsonMessage( Connector::lang( 'API returned an error. %s', $message ), 'ERROR' );
287
- }
288
- }
289
- else
290
- {
291
- InstapageHelper::writeDiagnostics( $text, 'message' );
292
- }
293
-
294
- return false;
295
- }
296
-
297
- return true;
298
- }
299
-
300
- public static function writeDiagnostics( $value, $name = '' )
301
- {
302
- $log = DebugLogModel::getInstance();
303
-
304
- if( $log->isDiagnosticMode() )
305
- {
306
- $log->write( $value, $name );
307
- }
308
- }
309
-
310
- public static function writeLog( $value, $name = '' )
311
- {
312
- $log = DebugLogModel::getInstance();
313
- $log->write( $value );
314
- }
315
-
316
- public static function getAuthHeader( $tokens )
317
- {
318
- self::writeDiagnostics( $tokens, 'Decoded tokens');
319
-
320
- return base64_encode( json_encode( $tokens ) );
321
- }
322
-
323
- public static function getVariant( $cookie_string )
324
- {
325
- $pattern = '/instapage-variant-\d*?=(.*?);/';
326
- $matches = array();
327
- preg_match( $pattern, $cookie_string, $matches );
328
-
329
- return isset( $matches[ 1 ] ) ? $matches[ 1 ] : null;
330
- }
331
-
332
- public static function httpResponseCode( $code = 200 )
333
- {
334
- if( function_exists( 'http_response_code' ) )
335
- {
336
- http_response_code( $code );
337
-
338
- return;
339
- }
340
-
341
- if( $code === NULL )
342
- {
343
- $code = 200;
344
- }
345
-
346
- switch( $code )
347
- {
348
- case 100: $text = 'Continue'; break;
349
- case 101: $text = 'Switching Protocols'; break;
350
- case 200: $text = 'OK'; break;
351
- case 201: $text = 'Created'; break;
352
- case 202: $text = 'Accepted'; break;
353
- case 203: $text = 'Non-Authoritative Information'; break;
354
- case 204: $text = 'No Content'; break;
355
- case 205: $text = 'Reset Content'; break;
356
- case 206: $text = 'Partial Content'; break;
357
- case 300: $text = 'Multiple Choices'; break;
358
- case 301: $text = 'Moved Permanently'; break;
359
- case 302: $text = 'Moved Temporarily'; break;
360
- case 303: $text = 'See Other'; break;
361
- case 304: $text = 'Not Modified'; break;
362
- case 305: $text = 'Use Proxy'; break;
363
- case 400: $text = 'Bad Request'; break;
364
- case 401: $text = 'Unauthorized'; break;
365
- case 402: $text = 'Payment Required'; break;
366
- case 403: $text = 'Forbidden'; break;
367
- case 404: $text = 'Not Found'; break;
368
- case 405: $text = 'Method Not Allowed'; break;
369
- case 406: $text = 'Not Acceptable'; break;
370
- case 407: $text = 'Proxy Authentication Required'; break;
371
- case 408: $text = 'Request Time-out'; break;
372
- case 409: $text = 'Conflict'; break;
373
- case 410: $text = 'Gone'; break;
374
- case 411: $text = 'Length Required'; break;
375
- case 412: $text = 'Precondition Failed'; break;
376
- case 413: $text = 'Request Entity Too Large'; break;
377
- case 414: $text = 'Request-URI Too Large'; break;
378
- case 415: $text = 'Unsupported Media Type'; break;
379
- case 500: $text = 'Internal Server Error'; break;
380
- case 501: $text = 'Not Implemented'; break;
381
- case 502: $text = 'Bad Gateway'; break;
382
- case 503: $text = 'Service Unavailable'; break;
383
- case 504: $text = 'Gateway Time-out'; break;
384
- case 505: $text = 'HTTP Version not supported'; break;
385
- default: $code = 200; $text = 'OK'; break;
386
- }
387
-
388
- $protocol = ( isset( $_SERVER[ 'SERVER_PROTOCOL' ] ) ? $_SERVER[ 'SERVER_PROTOCOL' ] : 'HTTP/1.1' );
389
- header( $protocol . ' ' . $code . ' ' . $text );
390
- $GLOBALS[ 'http_response_code' ] = $code;
391
- }
392
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
README.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: marek@instapage
3
  Tags: landing page, lead generation, a/b testing, Instapage, squeeze page, conversion rate optimization, splash page, WordPress landing page, landing page optimization, lead capture page, mobile app landing page, Facebook landing page, sales page
4
  Requires at least: 3.4
5
- Requires PHP: 5.2.4
6
- Tested up to: 5.4.0
7
  Stable tag: 3.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -55,6 +55,12 @@ Join 250,000+ businesses who rely on Instapage.
55
  4. Instapage app's dashboard.
56
 
57
  == Changelog ==
 
 
 
 
 
 
58
  = 3.2.14 (2020-04-30) =
59
  - Bugfix: Problems with OG and meta tags when using alternative loading system (visible when sharing in social media)
60
  - Bugfix: Rare error when using a specific set of plugins on Installed Plugins listing in WordPress admin
2
  Contributors: marek@instapage
3
  Tags: landing page, lead generation, a/b testing, Instapage, squeeze page, conversion rate optimization, splash page, WordPress landing page, landing page optimization, lead capture page, mobile app landing page, Facebook landing page, sales page
4
  Requires at least: 3.4
5
+ Requires PHP: 5.4.0
6
+ Tested up to: 5.7.1
7
  Stable tag: 3.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
55
  4. Instapage app's dashboard.
56
 
57
  == Changelog ==
58
+ = 3.3.0 (2021-04-26) =
59
+ - Ensure plugin core compatibility with PHP 8.0,
60
+ - New toggle for selecting communication protocol when making a call to Instapage services (https/http),
61
+ - Supports Instapage Experiment cookie's SameSite and Secure attributes
62
+ - Increased Tested up to: 5.7.1
63
+
64
  = 3.2.14 (2020-04-30) =
65
  - Bugfix: Problems with OG and meta tags when using alternative loading system (visible when sharing in social media)
66
  - Bugfix: Rare error when using a specific set of plugins on Installed Plugins listing in WordPress admin
connectors/InstapageCmsPluginConnector.php CHANGED
@@ -27,6 +27,17 @@ class InstapageCmsPluginConnector {
27
  return self::$selectedLanguage;
28
  }
29
 
 
 
 
 
 
 
 
 
 
 
 
30
  /**
31
  * Checks if WordPress is a currently used CMS.
32
  *
@@ -375,7 +386,7 @@ class InstapageCmsPluginConnector {
375
  ),
376
  array('label' => InstapageCmsPluginConnector::lang('PHP Curl extension or another way to make remote requests'), 'condition' => InstapageCmsPluginConnector::isAPIAccessible()),
377
  array('label' => InstapageCmsPluginConnector::lang('Enabled clean / SEO friendly URLs'), 'condition' => InstapageCmsPluginConnector::areSEOFriendlyUrlsEnabled()),
378
- array('label' => InstapageCmsPluginConnector::lang('Every request for landing page requires a request to our page server (http://pageserve.co) and this URL has to be accessible.'), 'condition' => InstapageCmsPluginConnector::isAPIAccessible())
379
  );
380
  $features = array_merge($features, $commonFeatures);
381
 
@@ -400,4 +411,19 @@ class InstapageCmsPluginConnector {
400
 
401
  return $html;
402
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
403
  }
27
  return self::$selectedLanguage;
28
  }
29
 
30
+ /**
31
+ * Checks if connector used in secured https:// env
32
+ * @return bool
33
+ */
34
+ public static function isSSL()
35
+ {
36
+ return in_array(filter_input(INPUT_SERVER, 'HTTPS'), ['on', 1])
37
+ || filter_input(INPUT_SERVER, 'HTTP_X_FORWARDED_PROTO') == 'https'
38
+ || filter_input(INPUT_SERVER, 'REQUEST_SCHEME') == 'https';
39
+ }
40
+
41
  /**
42
  * Checks if WordPress is a currently used CMS.
43
  *
386
  ),
387
  array('label' => InstapageCmsPluginConnector::lang('PHP Curl extension or another way to make remote requests'), 'condition' => InstapageCmsPluginConnector::isAPIAccessible()),
388
  array('label' => InstapageCmsPluginConnector::lang('Enabled clean / SEO friendly URLs'), 'condition' => InstapageCmsPluginConnector::areSEOFriendlyUrlsEnabled()),
389
+ array('label' => InstapageCmsPluginConnector::lang('Every request for landing page requires a request to our page server ('.InstapageCmsPluginConnector::getURLWithSelectedProtocol(INSTAPAGE_ENTERPRISE_ENDPOINT).') and this URL has to be accessible.'), 'condition' => InstapageCmsPluginConnector::isAPIAccessible())
390
  );
391
  $features = array_merge($features, $commonFeatures);
392
 
411
 
412
  return $html;
413
  }
414
+
415
+ /**
416
+ * Toggles ssl on/off in given url
417
+ *
418
+ * @param $url
419
+ * @uses InstapageCmsPluginHelper::getOption()
420
+ * @return string
421
+ */
422
+ public static function getURLWithSelectedProtocol($url)
423
+ {
424
+ $useHttpsProtocol = InstapageCmsPluginHelper::getOption('ssl', false);
425
+ $protocolsToToggle = ['http://', 'https://'];
426
+ list($search, $replace) = $useHttpsProtocol ? $protocolsToToggle : array_reverse($protocolsToToggle);
427
+ return str_ireplace($search, $replace, $url);
428
+ }
429
  }
connectors/InstapageCmsPluginDrupal7Connector.php CHANGED
@@ -182,9 +182,9 @@ class InstapageCmsPluginDrupal7Connector {
182
  $response = $this->remoteGet(INSTAPAGE_ENTERPRISE_ENDPOINT, array());
183
 
184
  $body = is_string($response['body']) && is_object(json_decode($response['body'])) ? json_decode($response['body']) : null ;
185
-
186
  return (
187
- is_object($body) &&
188
  isset($body->status) && $body->status === 'ERROR' &&
189
  isset($body->message) && stripos($body->message, 'Request failed') !== false
190
  );
@@ -412,7 +412,7 @@ class InstapageCmsPluginDrupal7Connector {
412
  $dataString = '';
413
  }
414
 
415
- $cookies = @InstapageCmsPluginHelper::getVar($data['cookies'], array());
416
  $cookieString = '';
417
 
418
  foreach ($cookies as $key => $cookie) {
@@ -438,8 +438,8 @@ class InstapageCmsPluginDrupal7Connector {
438
  } else {
439
  return [
440
  'body' => json_encode([
441
- 'status' => 'ERROR',
442
- 'message' => InstapageCmsPluginConnector::lang('Request failed with status %s.', $request->code)
443
  ])
444
  ];
445
  }
@@ -472,6 +472,7 @@ class InstapageCmsPluginDrupal7Connector {
472
  * @return array Request result in a form of associative array.
473
  */
474
  public function remoteGet($url, $data, $headers = array()) {
 
475
  return $this->remoteRequest($url, $data, $headers, 'GET');
476
  }
477
 
@@ -549,7 +550,7 @@ class InstapageCmsPluginDrupal7Connector {
549
  * Initiates Instapage plugin's DB structure and loads plugin's classes.
550
  */
551
  public function initPlugin() {
552
- $action = InstapageCmsPluginHelper::getVar($_GET['action'], '');
553
 
554
  if ($action == 'instapage_ajax_call') {
555
  $this->ajaxCallback();
@@ -762,7 +763,7 @@ class InstapageCmsPluginDrupal7Connector {
762
  $sitename = variable_get('site_name');
763
 
764
  if ($sanitized) {
765
- return mb_strtolower(str_replace(' ', '-', $sitename));
766
  }
767
 
768
  return $sitename;
182
  $response = $this->remoteGet(INSTAPAGE_ENTERPRISE_ENDPOINT, array());
183
 
184
  $body = is_string($response['body']) && is_object(json_decode($response['body'])) ? json_decode($response['body']) : null ;
185
+
186
  return (
187
+ is_object($body) &&
188
  isset($body->status) && $body->status === 'ERROR' &&
189
  isset($body->message) && stripos($body->message, 'Request failed') !== false
190
  );
412
  $dataString = '';
413
  }
414
 
415
+ $cookies = isset($data['cookies']) ? $data['cookies'] : array();
416
  $cookieString = '';
417
 
418
  foreach ($cookies as $key => $cookie) {
438
  } else {
439
  return [
440
  'body' => json_encode([
441
+ 'status' => 'ERROR',
442
+ 'message' => InstapageCmsPluginConnector::lang('Request failed with status %s.', $request->code)
443
  ])
444
  ];
445
  }
472
  * @return array Request result in a form of associative array.
473
  */
474
  public function remoteGet($url, $data, $headers = array()) {
475
+ $url = InstapageCmsPluginConnector::getURLWithSelectedProtocol($url);
476
  return $this->remoteRequest($url, $data, $headers, 'GET');
477
  }
478
 
550
  * Initiates Instapage plugin's DB structure and loads plugin's classes.
551
  */
552
  public function initPlugin() {
553
+ $action = filter_input(INPUT_GET, 'action');
554
 
555
  if ($action == 'instapage_ajax_call') {
556
  $this->ajaxCallback();
763
  $sitename = variable_get('site_name');
764
 
765
  if ($sanitized) {
766
+ return mb_strtolower(str_replace(' ', '-', $sitename), 'UTF-8');
767
  }
768
 
769
  return $sitename;
connectors/InstapageCmsPluginDrupal8Connector.php CHANGED
@@ -47,9 +47,9 @@ class InstapageCmsPluginDrupal8Connector {
47
  $response = $this->remoteGet(INSTAPAGE_ENTERPRISE_ENDPOINT, array());
48
 
49
  $body = is_string($response['body']) && is_object(json_decode($response['body'])) ? json_decode($response['body']) : null ;
50
-
51
  return (
52
- is_object($body) &&
53
  isset($body->status) && $body->status === 'ERROR' &&
54
  isset($body->message) && stripos($body->message, 'Request failed') !== false
55
  );
@@ -255,7 +255,7 @@ class InstapageCmsPluginDrupal8Connector {
255
  $formParams = array();
256
  }
257
 
258
- $cookies = @InstapageCmsPluginHelper::getVar($data['cookies'], array());
259
  $cookieJar = false;
260
 
261
  if (!empty($cookies)) {
@@ -285,17 +285,17 @@ class InstapageCmsPluginDrupal8Connector {
285
  } else {
286
  return [
287
  'body' => json_encode([
288
- 'status' => 'ERROR',
289
- 'message' => InstapageCmsPluginConnector::lang('Request failed with status %s.', $request->getStatusCode())
290
  ])
291
  ];
292
  }
293
  } catch (Exception $e) {
294
  return [
295
  'body' => json_encode([
296
- 'status' => 'ERROR',
297
- 'message' => InstapageCmsPluginConnector::lang('Request failed. ') .
298
- $e->getMessage()
299
  ])
300
  ];
301
  }
@@ -327,6 +327,7 @@ class InstapageCmsPluginDrupal8Connector {
327
  * @return array Request result in a form of associative array.
328
  */
329
  public function remoteGet($url, $data, $headers = array()) {
 
330
  return $this->remoteRequest($url, $data, $headers, 'GET');
331
  }
332
 
@@ -340,7 +341,7 @@ class InstapageCmsPluginDrupal8Connector {
340
  */
341
  private function prepareResponse($request) {
342
  $headers = $request->getHeaders();
343
- $headers['set-cookie'] = @InstapageCmsPluginHelper::getVar($headers['Set-Cookie'][0], '');
344
 
345
  return array(
346
  'body' => (string) $request->getBody(),
@@ -425,7 +426,7 @@ class InstapageCmsPluginDrupal8Connector {
425
  * Initiates Instapage plugin's DB structure and loads plugin's classes.
426
  */
427
  public function initPlugin() {
428
- $action = InstapageCmsPluginHelper::getVar($_GET['action'], '');
429
 
430
  if ($action == 'instapage_ajax_call') {
431
  $this->ajaxCallback();
@@ -644,7 +645,7 @@ class InstapageCmsPluginDrupal8Connector {
644
  $sitename = \Drupal::config('system.site')->get('name');
645
 
646
  if ($sanitized) {
647
- return mb_strtolower(str_replace(' ', '-', $sitename));
648
  }
649
 
650
  return $sitename;
47
  $response = $this->remoteGet(INSTAPAGE_ENTERPRISE_ENDPOINT, array());
48
 
49
  $body = is_string($response['body']) && is_object(json_decode($response['body'])) ? json_decode($response['body']) : null ;
50
+
51
  return (
52
+ is_object($body) &&
53
  isset($body->status) && $body->status === 'ERROR' &&
54
  isset($body->message) && stripos($body->message, 'Request failed') !== false
55
  );
255
  $formParams = array();
256
  }
257
 
258
+ $cookies = isset($data['cookies']) ? $data['cookies'] : array();
259
  $cookieJar = false;
260
 
261
  if (!empty($cookies)) {
285
  } else {
286
  return [
287
  'body' => json_encode([
288
+ 'status' => 'ERROR',
289
+ 'message' => InstapageCmsPluginConnector::lang('Request failed with status %s.', $request->getStatusCode())
290
  ])
291
  ];
292
  }
293
  } catch (Exception $e) {
294
  return [
295
  'body' => json_encode([
296
+ 'status' => 'ERROR',
297
+ 'message' => InstapageCmsPluginConnector::lang('Request failed. ') .
298
+ $e->getMessage()
299
  ])
300
  ];
301
  }
327
  * @return array Request result in a form of associative array.
328
  */
329
  public function remoteGet($url, $data, $headers = array()) {
330
+ $url = InstapageCmsPluginConnector::getURLWithSelectedProtocol($url);
331
  return $this->remoteRequest($url, $data, $headers, 'GET');
332
  }
333
 
341
  */
342
  private function prepareResponse($request) {
343
  $headers = $request->getHeaders();
344
+ $headers['set-cookie'] = isset($headers['Set-Cookie'][0]) ? $headers['Set-Cookie'][0] : '';
345
 
346
  return array(
347
  'body' => (string) $request->getBody(),
426
  * Initiates Instapage plugin's DB structure and loads plugin's classes.
427
  */
428
  public function initPlugin() {
429
+ $action = filter_input(INPUT_GET, 'action');
430
 
431
  if ($action == 'instapage_ajax_call') {
432
  $this->ajaxCallback();
645
  $sitename = \Drupal::config('system.site')->get('name');
646
 
647
  if ($sanitized) {
648
+ return mb_strtolower(str_replace(' ', '-', $sitename), 'UTF-8');
649
  }
650
 
651
  return $sitename;
connectors/InstapageCmsPluginWPConnector.php CHANGED
@@ -212,7 +212,7 @@ class InstapageCmsPluginWPConnector {
212
  InstapageCmsPluginHelper::writeDiagnostics($url, 'GET Request URL');
213
  }
214
 
215
- $cookies = @InstapageCmsPluginHelper::getVar($data['cookies'], array());
216
 
217
  $args = array(
218
  'method' => $method,
@@ -278,6 +278,7 @@ class InstapageCmsPluginWPConnector {
278
  * @return array Request result in a form of associative array.
279
  */
280
  public function remoteGet($url, $data, $headers = array()) {
 
281
  return $this->remoteRequest($url, $data, $headers, 'GET');
282
  }
283
 
@@ -523,7 +524,7 @@ class InstapageCmsPluginWPConnector {
523
  * @return bool True if current URL is login page.
524
  */
525
  public function isLoginPage() {
526
- $pagenow = InstapageCmsPluginHelper::getVar($GLOBALS['pagenowfff'], 'undefined');
527
 
528
  return in_array($pagenow, array('wp-login.php', 'wp-register.php'));
529
  }
@@ -1091,26 +1092,26 @@ class InstapageCmsPluginWPConnector {
1091
  * @return array Standard Instapage plugin request response array.
1092
  */
1093
  private function prepareResponse($request) {
1094
- $headers = @InstapageCmsPluginHelper::getVar($request['headers'], null);
1095
 
1096
  if (is_object($headers) && get_class($headers) == 'Requests_Utility_CaseInsensitiveDictionary') {
1097
  $headers = $headers->getAll();
1098
  }
1099
 
1100
- $responseCode = @InstapageCmsPluginHelper::getVar($request['status_code'], 0);
1101
 
1102
  if (!$responseCode) {
1103
- $responseCode = @InstapageCmsPluginHelper::getVar($request['response']['code'], 200);
1104
  }
1105
 
1106
- $status = @InstapageCmsPluginHelper::getVar($request['status'], '');
1107
 
1108
  if (!$status) {
1109
- $status = @InstapageCmsPluginHelper::getVar($request['response']['message'], '');
1110
  }
1111
 
1112
  return array(
1113
- 'body' => @InstapageCmsPluginHelper::getVar($request['body'], ''),
1114
  'status' => $status,
1115
  'code' => $responseCode,
1116
  'headers' => $headers
212
  InstapageCmsPluginHelper::writeDiagnostics($url, 'GET Request URL');
213
  }
214
 
215
+ $cookies = isset($data['cookies']) ? $data['cookies'] : array();
216
 
217
  $args = array(
218
  'method' => $method,
278
  * @return array Request result in a form of associative array.
279
  */
280
  public function remoteGet($url, $data, $headers = array()) {
281
+ $url = InstapageCmsPluginConnector::getURLWithSelectedProtocol($url);
282
  return $this->remoteRequest($url, $data, $headers, 'GET');
283
  }
284
 
524
  * @return bool True if current URL is login page.
525
  */
526
  public function isLoginPage() {
527
+ $pagenow = isset($GLOBALS['pagenowfff']) ? $GLOBALS['pagenowfff'] : 'undefined';
528
 
529
  return in_array($pagenow, array('wp-login.php', 'wp-register.php'));
530
  }
1092
  * @return array Standard Instapage plugin request response array.
1093
  */
1094
  private function prepareResponse($request) {
1095
+ $headers = isset($request['headers']) ? $request['headers'] : null;
1096
 
1097
  if (is_object($headers) && get_class($headers) == 'Requests_Utility_CaseInsensitiveDictionary') {
1098
  $headers = $headers->getAll();
1099
  }
1100
 
1101
+ $responseCode = isset($request['status_code']) ? $request['status_code'] : 0;
1102
 
1103
  if (!$responseCode) {
1104
+ $responseCode = isset($request['response']['code']) ? $request['response']['code'] : 200;
1105
  }
1106
 
1107
+ $status = isset($request['status']) ? $request['status'] : '';
1108
 
1109
  if (!$status) {
1110
+ $status = isset($request['response']['message']) ? $request['response']['message'] : '';
1111
  }
1112
 
1113
  return array(
1114
+ 'body' => isset($request['body']) ? $request['body'] : '',
1115
  'status' => $status,
1116
  'code' => $responseCode,
1117
  'headers' => $headers
instapage.php CHANGED
@@ -3,8 +3,8 @@
3
  /*
4
  Plugin Name: Instapage Plugin
5
  Description: The best way for WordPress to seamlessly publish landing pages as a natural extension of your website.
6
- Version: 3.2.14
7
- Requires PHP: 5.2.4
8
  Plugin URI: https://instapage.com/
9
  Author: Instapage
10
  Author URI: https://instapage.com/
3
  /*
4
  Plugin Name: Instapage Plugin
5
  Description: The best way for WordPress to seamlessly publish landing pages as a natural extension of your website.
6
+ Version: 3.3.0
7
+ Requires PHP: 5.4.0
8
  Plugin URI: https://instapage.com/
9
  Author: Instapage
10
  Author URI: https://instapage.com/
knockout/view_models/InstapageCmsPluginSettingsModel.js CHANGED
@@ -1,9 +1,11 @@
1
  /* globals ko, instapageKO, iAjax, iLang, masterModel, INSTAPAGE_AJAXURL, download */
2
 
3
- var InstapageCmsPluginSettingsModel = function InstapageCmsPluginSettingsModel(data) {
4
  var self = this;
5
 
6
- self.email = (data && data.user_name) ? instapageKO.observable(decodeURIComponent(data.user_name)) : instapageKO.observable();
 
 
7
  self.userToken = (data && data.plugin_hash) ? instapageKO.observable(data.plugin_hash) : instapageKO.observable();
8
  self.password = instapageKO.observable();
9
  self.clearLog = instapageKO.observable();
@@ -14,11 +16,18 @@ var InstapageCmsPluginSettingsModel = function InstapageCmsPluginSettingsModel(d
14
  self.connectedTokens = instapageKO.observableArray();
15
  self.hideConnectedTokens = instapageKO.observable(true);
16
  self.metadata = (data && data.metadata) ? JSON.parse(data.metadata) : {};
17
- self.supportLegacy = (typeof self.metadata.supportLegacy !== 'undefined') ? instapageKO.observable(self.metadata.supportLegacy) : instapageKO.observable(true);
18
- self.lpAjaxLoader = (typeof self.metadata.lpAjaxLoader !== 'undefined') ? instapageKO.observable(self.metadata.lpAjaxLoader) : instapageKO.observable(false);
 
 
 
 
19
 
20
  self.loginUser = function loginUser() {
21
- var post = {action: 'loginUser', data: {email: encodeURIComponent(self.email()), password: encodeURIComponent(self.password())}};
 
 
 
22
  iAjax.post(INSTAPAGE_AJAXURL, post, function loginUserCallback(responseJson) {
23
  var response = masterModel.parseResponse(responseJson);
24
 
@@ -66,7 +75,12 @@ var InstapageCmsPluginSettingsModel = function InstapageCmsPluginSettingsModel(d
66
  };
67
 
68
  self.getConfig = function getConfig() {
69
- return {crossOrigin: self.config.crossOrigin(), diagnostics: self.config.diagnostics(), customParams: self.config.customParams()};
 
 
 
 
 
70
  };
71
 
72
  self.addToken = function addToken() {
@@ -109,7 +123,15 @@ var InstapageCmsPluginSettingsModel = function InstapageCmsPluginSettingsModel(d
109
  var configObj = instapageKO.toJS(self.config);
110
  var metadataObj = instapageKO.toJS(self.metadata);
111
  var email = (typeof self.email() !== 'undefined') ? self.email() : '';
112
- var post = {action: 'updateOptions', data: {config: configObj, metadata: metadataObj, userName: encodeURIComponent(email), userToken: self.userToken()}};
 
 
 
 
 
 
 
 
113
 
114
  iAjax.post(INSTAPAGE_AJAXURL, post, function saveConfigCallback(responseJson) {
115
  var response = masterModel.parseResponse(responseJson);
@@ -258,7 +280,10 @@ var InstapageCmsPluginSettingsModel = function InstapageCmsPluginSettingsModel(d
258
  });
259
  };
260
 
261
- self.disconnectAccountBoundSubaccounts = function disconnectAccountBoundSubaccounts(onSuccessFunction, onFailureFunction) {
 
 
 
262
  var post = {action: 'disconnectAccountBoundSubaccounts'};
263
 
264
  iAjax.post(INSTAPAGE_AJAXURL, post, function disconnectAccountBoundSubaccountsCallback(responseJson) {
@@ -329,12 +354,13 @@ var InstapageCmsPluginSettingsModel = function InstapageCmsPluginSettingsModel(d
329
  }
330
  };
331
 
332
- var PluginConfig = function PluginConfig(data) {
333
  var self = this;
334
 
335
  self.crossOrigin = data ? instapageKO.observable(data.crossOrigin) : instapageKO.observable(false);
336
  self.diagnostics = data ? instapageKO.observable(data.diagnostics) : instapageKO.observable(false);
337
  self.customParams = data ? instapageKO.observable(data.customParams) : instapageKO.observable('');
 
338
  self.tokens = instapageKO.observableArray();
339
 
340
  if ( data && data.tokens && Array.isArray(data.tokens) ) {
1
  /* globals ko, instapageKO, iAjax, iLang, masterModel, INSTAPAGE_AJAXURL, download */
2
 
3
+ const InstapageCmsPluginSettingsModel = function InstapageCmsPluginSettingsModel(data) {
4
  var self = this;
5
 
6
+ self.email = (data && data.user_name)
7
+ ? instapageKO.observable(decodeURIComponent(data.user_name))
8
+ : instapageKO.observable();
9
  self.userToken = (data && data.plugin_hash) ? instapageKO.observable(data.plugin_hash) : instapageKO.observable();
10
  self.password = instapageKO.observable();
11
  self.clearLog = instapageKO.observable();
16
  self.connectedTokens = instapageKO.observableArray();
17
  self.hideConnectedTokens = instapageKO.observable(true);
18
  self.metadata = (data && data.metadata) ? JSON.parse(data.metadata) : {};
19
+ self.supportLegacy = (typeof self.metadata.supportLegacy !== 'undefined')
20
+ ? instapageKO.observable(self.metadata.supportLegacy)
21
+ : instapageKO.observable(true);
22
+ self.lpAjaxLoader = (typeof self.metadata.lpAjaxLoader !== 'undefined')
23
+ ? instapageKO.observable(self.metadata.lpAjaxLoader)
24
+ : instapageKO.observable(false);
25
 
26
  self.loginUser = function loginUser() {
27
+ let post = {
28
+ action: 'loginUser',
29
+ data: {email: encodeURIComponent(self.email()), password: encodeURIComponent(self.password())},
30
+ };
31
  iAjax.post(INSTAPAGE_AJAXURL, post, function loginUserCallback(responseJson) {
32
  var response = masterModel.parseResponse(responseJson);
33
 
75
  };
76
 
77
  self.getConfig = function getConfig() {
78
+ return {
79
+ crossOrigin: self.config.crossOrigin(),
80
+ diagnostics: self.config.diagnostics(),
81
+ customParams: self.config.customParams(),
82
+ ssl: self.config.ssl(),
83
+ };
84
  };
85
 
86
  self.addToken = function addToken() {
123
  var configObj = instapageKO.toJS(self.config);
124
  var metadataObj = instapageKO.toJS(self.metadata);
125
  var email = (typeof self.email() !== 'undefined') ? self.email() : '';
126
+ const post = {
127
+ action: 'updateOptions',
128
+ data: {
129
+ config: configObj,
130
+ metadata: metadataObj,
131
+ userName: encodeURIComponent(email),
132
+ userToken: self.userToken(),
133
+ },
134
+ };
135
 
136
  iAjax.post(INSTAPAGE_AJAXURL, post, function saveConfigCallback(responseJson) {
137
  var response = masterModel.parseResponse(responseJson);
280
  });
281
  };
282
 
283
+ self.disconnectAccountBoundSubaccounts = function disconnectAccountBoundSubaccounts(
284
+ onSuccessFunction,
285
+ onFailureFunction
286
+ ) {
287
  var post = {action: 'disconnectAccountBoundSubaccounts'};
288
 
289
  iAjax.post(INSTAPAGE_AJAXURL, post, function disconnectAccountBoundSubaccountsCallback(responseJson) {
354
  }
355
  };
356
 
357
+ const PluginConfig = function PluginConfig(data) {
358
  var self = this;
359
 
360
  self.crossOrigin = data ? instapageKO.observable(data.crossOrigin) : instapageKO.observable(false);
361
  self.diagnostics = data ? instapageKO.observable(data.diagnostics) : instapageKO.observable(false);
362
  self.customParams = data ? instapageKO.observable(data.customParams) : instapageKO.observable('');
363
+ self.ssl = data ? instapageKO.observable(data.ssl) : instapageKO.observable(false);
364
  self.tokens = instapageKO.observableArray();
365
 
366
  if ( data && data.tokens && Array.isArray(data.tokens) ) {
models/InstapageCmsPluginAPIModel.php CHANGED
@@ -50,8 +50,8 @@ class InstapageCmsPluginAPIModel {
50
  $data['useragent'] = $_SERVER['HTTP_USER_AGENT'];
51
  $data['ip'] = $_SERVER['REMOTE_ADDR'];
52
  $data['cookies'] = $cookies;
53
- $data['custom'] = @InstapageCmsPluginHelper::getVar($_GET['custom'], null);
54
- $data['variant'] = @InstapageCmsPluginHelper::getVar($_GET['variant'], null);
55
  $data['requestHost'] = $host;
56
  $headers['integration'] = $integration;
57
  $headers['host'] = $host;
@@ -78,7 +78,7 @@ class InstapageCmsPluginAPIModel {
78
  */
79
  public function apiCall($action, $data = array(), $headers = array(), $method = 'POST') {
80
  $integration = InstapageCmsPluginConnector::getSelectedConnector()->name;
81
- $url = INSTAPAGE_APP_ENDPOINT . '/' . $action;
82
  $headers['integration'] = $integration;
83
  $response = InstapageCmsPluginConnector::getSelectedConnector()->remoteRequest($url, $data, $headers, $method);
84
 
50
  $data['useragent'] = $_SERVER['HTTP_USER_AGENT'];
51
  $data['ip'] = $_SERVER['REMOTE_ADDR'];
52
  $data['cookies'] = $cookies;
53
+ $data['custom'] = filter_input(INPUT_GET, 'custom');
54
+ $data['variant'] = filter_input(INPUT_GET, 'variant');
55
  $data['requestHost'] = $host;
56
  $headers['integration'] = $integration;
57
  $headers['host'] = $host;
78
  */
79
  public function apiCall($action, $data = array(), $headers = array(), $method = 'POST') {
80
  $integration = InstapageCmsPluginConnector::getSelectedConnector()->name;
81
+ $url = InstapageCmsPluginConnector::getURLWithSelectedProtocol(INSTAPAGE_APP_ENDPOINT . '/' . $action);
82
  $headers['integration'] = $integration;
83
  $response = InstapageCmsPluginConnector::getSelectedConnector()->remoteRequest($url, $data, $headers, $method);
84
 
models/InstapageCmsPluginDebugLogModel.php CHANGED
@@ -48,7 +48,7 @@ class InstapageCmsPluginDebugLogModel {
48
  $caller = '';
49
 
50
  if ($addCaller) {
51
- $trace = debug_backtrace();
52
  $traceLength = 3;
53
  $callerArr = array();
54
 
@@ -155,34 +155,34 @@ class InstapageCmsPluginDebugLogModel {
155
 
156
  /**
157
  * Gets database structure
158
- *
159
  * @uses InstapageCmsPluginDBModel::getInstance()
160
- *
161
- * @return array Array of table structure descriptions
162
  */
163
  protected function getDbStructure() {
164
  $db = InstapageCmsPluginDBModel::getInstance();
165
  $tablesDescriptions = array();
166
-
167
  // get description of tables
168
  $sql = 'DESCRIBE ' . $db->pagesTable;
169
  $tablesDescriptions[] = [
170
  'tableName' => $db->pagesTable,
171
  'description' => $db->getResults($sql)
172
  ];
173
-
174
  $sql = 'DESCRIBE ' . $db->optionsTable;
175
  $tablesDescriptions[] = [
176
  'tableName' => $db->optionsTable,
177
  'description' => $db->getResults($sql)
178
  ];
179
-
180
  $sql = 'DESCRIBE ' . $db->debugTable;
181
  $tablesDescriptions[] = [
182
  'tableName' => $db->debugTable,
183
  'description' => $db->getResults($sql)
184
  ];
185
-
186
  return $tablesDescriptions;
187
  }
188
  }
48
  $caller = '';
49
 
50
  if ($addCaller) {
51
+ $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
52
  $traceLength = 3;
53
  $callerArr = array();
54
 
155
 
156
  /**
157
  * Gets database structure
158
+ *
159
  * @uses InstapageCmsPluginDBModel::getInstance()
160
+ *
161
+ * @return array Array of table structure descriptions
162
  */
163
  protected function getDbStructure() {
164
  $db = InstapageCmsPluginDBModel::getInstance();
165
  $tablesDescriptions = array();
166
+
167
  // get description of tables
168
  $sql = 'DESCRIBE ' . $db->pagesTable;
169
  $tablesDescriptions[] = [
170
  'tableName' => $db->pagesTable,
171
  'description' => $db->getResults($sql)
172
  ];
173
+
174
  $sql = 'DESCRIBE ' . $db->optionsTable;
175
  $tablesDescriptions[] = [
176
  'tableName' => $db->optionsTable,
177
  'description' => $db->getResults($sql)
178
  ];
179
+
180
  $sql = 'DESCRIBE ' . $db->debugTable;
181
  $tablesDescriptions[] = [
182
  'tableName' => $db->debugTable,
183
  'description' => $db->getResults($sql)
184
  ];
185
+
186
  return $tablesDescriptions;
187
  }
188
  }
models/InstapageCmsPluginPageModel.php CHANGED
@@ -36,10 +36,10 @@ class InstapageCmsPluginPageModel {
36
  * @return integer|boolean Insert ID of false on error.
37
  */
38
  public function update($data) {
39
- $id = InstapageCmsPluginHelper::getVar($data->id, 0);
40
- $instapageId = InstapageCmsPluginHelper::getVar($data->landingPageId, null);
41
- $type = InstapageCmsPluginHelper::getVar($data->type);
42
- $slug = InstapageCmsPluginHelper::getVar($data->slug);
43
  $enterpriseUrl = InstapageCmsPluginConnector::getHomeURL();
44
 
45
  if ($slug) {
@@ -190,15 +190,15 @@ class InstapageCmsPluginPageModel {
190
  $subaccount = InstapageCmsPluginSubaccountModel::getInstance();
191
  $url = $data->slug ? InstapageCmsPluginConnector::getHomeURL() . '/' . $data->slug : InstapageCmsPluginConnector::getHomeURL();
192
  $url = InstapageCmsPluginHelper::prepareUrlForUpdate($url);
193
- $tokens = InstapageCmsPluginHelper::getVar($data->apiTokens, false);
194
  $success = true;
195
 
196
  if (!$tokens) {
197
  $tokens = $subaccount->getAllTokens();
198
  }
199
 
200
- $oldPageId = InstapageCmsPluginHelper::getVar($data->id, null);
201
- $newInstapageId = InstapageCmsPluginHelper::getVar($data->landingPageId, null);
202
 
203
  if ($oldPageId) {
204
  $oldPage = $this->get($oldPageId, array('instapage_id'));
@@ -450,6 +450,7 @@ class InstapageCmsPluginPageModel {
450
 
451
  $url = preg_replace('/https?:\/\/' . $host . '/', INSTAPAGE_ENTERPRISE_ENDPOINT, $page->enterprise_url);
452
  $url .= $querySufix;
 
453
 
454
  $enterpriseCallResult = $api->enterpriseCall($url, $host, $cookies);
455
  $html = $this->getLandingPageHTMLFromTheApp($enterpriseCallResult);
@@ -463,7 +464,7 @@ class InstapageCmsPluginPageModel {
463
  if ($forcedStatus) {
464
  $status = $forcedStatus;
465
  } else {
466
- $status = InstapageCmsPluginHelper::getVar($enterpriseCallResult['code'], 200);
467
  }
468
 
469
  if ($html) {
@@ -486,7 +487,7 @@ class InstapageCmsPluginPageModel {
486
  */
487
  public function getLandingPageHTMLFromTheApp($enterpriseCallResult)
488
  {
489
- $html = InstapageCmsPluginHelper::getVar($enterpriseCallResult['body']);
490
  $html = $this->disableCloudFlareScriptReplace($html);
491
  $html = $this->fixHtmlHead($html);
492
 
@@ -510,11 +511,32 @@ class InstapageCmsPluginPageModel {
510
  $instapageVariant = InstapageCmsPluginHelper::getVariant((string) $pageserverCookie);
511
 
512
  if (!empty($instapageVariant)) {
513
- setcookie(
514
- "instapage-variant-{$instapageId}",
515
- $instapageVariant,
516
- strtotime('+12 month')
517
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
518
  }
519
  }
520
 
36
  * @return integer|boolean Insert ID of false on error.
37
  */
38
  public function update($data) {
39
+ $id = isset($data->id) ? $data->id : 0;
40
+ $instapageId = isset($data->landingPageId) ? $data->landingPageId : null;
41
+ $type = isset($data->type) ? $data->type : false;
42
+ $slug = isset($data->slug) ? $data->slug : false;
43
  $enterpriseUrl = InstapageCmsPluginConnector::getHomeURL();
44
 
45
  if ($slug) {
190
  $subaccount = InstapageCmsPluginSubaccountModel::getInstance();
191
  $url = $data->slug ? InstapageCmsPluginConnector::getHomeURL() . '/' . $data->slug : InstapageCmsPluginConnector::getHomeURL();
192
  $url = InstapageCmsPluginHelper::prepareUrlForUpdate($url);
193
+ $tokens = isset($data->apiTokens) ? $data->apiTokens : false;
194
  $success = true;
195
 
196
  if (!$tokens) {
197
  $tokens = $subaccount->getAllTokens();
198
  }
199
 
200
+ $oldPageId = isset($data->id) ? $data->id : null;
201
+ $newInstapageId = isset($data->landingPageId) ? $data->landingPageId : null;
202
 
203
  if ($oldPageId) {
204
  $oldPage = $this->get($oldPageId, array('instapage_id'));
450
 
451
  $url = preg_replace('/https?:\/\/' . $host . '/', INSTAPAGE_ENTERPRISE_ENDPOINT, $page->enterprise_url);
452
  $url .= $querySufix;
453
+ $url = InstapageCmsPluginConnector::getURLWithSelectedProtocol($url);
454
 
455
  $enterpriseCallResult = $api->enterpriseCall($url, $host, $cookies);
456
  $html = $this->getLandingPageHTMLFromTheApp($enterpriseCallResult);
464
  if ($forcedStatus) {
465
  $status = $forcedStatus;
466
  } else {
467
+ $status = isset($enterpriseCallResult['code']) ? $enterpriseCallResult['code'] : 200;
468
  }
469
 
470
  if ($html) {
487
  */
488
  public function getLandingPageHTMLFromTheApp($enterpriseCallResult)
489
  {
490
+ $html = isset($enterpriseCallResult['body']) ? $enterpriseCallResult['body'] : false;
491
  $html = $this->disableCloudFlareScriptReplace($html);
492
  $html = $this->fixHtmlHead($html);
493
 
511
  $instapageVariant = InstapageCmsPluginHelper::getVariant((string) $pageserverCookie);
512
 
513
  if (!empty($instapageVariant)) {
514
+ $variantCookieName = "instapage-variant-{$instapageId}";
515
+ $variantCookieOptions = [
516
+ 'expires' => strtotime('+12 month'),
517
+ 'path' => '/',
518
+ 'domain' => '',
519
+ 'samesite' => 'None',
520
+ 'secure' => InstapageCmsPluginConnector::isSSL()
521
+ ];
522
+
523
+ if (version_compare(phpversion(), '7.3', '<')) {
524
+ $variantCookiePath = $variantCookieOptions['domain'] . '; samesite=' . $variantCookieOptions['samesite'];
525
+ setcookie(
526
+ $variantCookieName,
527
+ $instapageVariant,
528
+ $variantCookieOptions['expires'],
529
+ $variantCookiePath,
530
+ $variantCookieOptions['domain'],
531
+ $variantCookieOptions['secure']
532
+ );
533
+ } else {
534
+ setcookie(
535
+ $variantCookieName,
536
+ $instapageVariant,
537
+ $variantCookieOptions
538
+ );
539
+ }
540
  }
541
  }
542
 
models/InstapageCmsPluginServicesModel.php CHANGED
@@ -52,13 +52,13 @@ class InstapageCmsPluginServicesModel {
52
  */
53
  public function processProxyServices() {
54
  $api = InstapageCmsPluginAPIModel::getInstance();
55
- $url = @InstapageCmsPluginHelper::getVar($_GET['url'], '');
56
 
57
  if (strpos($url, 'ajax/pageserver/email') === false) {
58
  throw new Exception('Unsupported endpoint: ' . $url);
59
  }
60
 
61
- $url = INSTAPAGE_PROXY_ENDPOINT . $url;
62
 
63
  array_walk_recursive($_POST, array($this, 'stripSlashesGpc'));
64
 
@@ -81,11 +81,11 @@ class InstapageCmsPluginServicesModel {
81
  InstapageCmsPluginHelper::writeDiagnostics($data, 'Proxy data');
82
  InstapageCmsPluginHelper::writeDiagnostics($response, 'Proxy response');
83
 
84
- $status = @InstapageCmsPluginHelper::getVar($response->status);
85
- $responseCode = @InstapageCmsPluginHelper::getVar($response['response']['code'], 200);
86
 
87
  if ($status === 'ERROR') {
88
- $errorMessage = @InstapageCmsPluginHelper::getVar($response->message);
89
 
90
  if (!empty($errorMessage)) {
91
  throw new Exception($errorMessage);
@@ -98,7 +98,7 @@ class InstapageCmsPluginServicesModel {
98
  ob_start();
99
  ob_end_clean();
100
  header('Content-Type: text/json; charset=UTF-8');
101
- echo trim(@InstapageCmsPluginHelper::getVar($response['body'], ''));
102
  status_header($responseCode);
103
 
104
  exit;
52
  */
53
  public function processProxyServices() {
54
  $api = InstapageCmsPluginAPIModel::getInstance();
55
+ $url = filter_input(INPUT_GET, 'url');
56
 
57
  if (strpos($url, 'ajax/pageserver/email') === false) {
58
  throw new Exception('Unsupported endpoint: ' . $url);
59
  }
60
 
61
+ $url = InstapageCmsPluginConnector::getURLWithSelectedProtocol(INSTAPAGE_PROXY_ENDPOINT . $url);
62
 
63
  array_walk_recursive($_POST, array($this, 'stripSlashesGpc'));
64
 
81
  InstapageCmsPluginHelper::writeDiagnostics($data, 'Proxy data');
82
  InstapageCmsPluginHelper::writeDiagnostics($response, 'Proxy response');
83
 
84
+ $status = isset($response->status) ? $response->status : false;
85
+ $responseCode = isset($response['response']['code']) ? $response['response']['code'] : 200;
86
 
87
  if ($status === 'ERROR') {
88
+ $errorMessage = isset($response->message) ? $response->message : false;
89
 
90
  if (!empty($errorMessage)) {
91
  throw new Exception($errorMessage);
98
  ob_start();
99
  ob_end_clean();
100
  header('Content-Type: text/json; charset=UTF-8');
101
+ echo trim(isset($response['body']) ? $response['body'] : '');
102
  status_header($responseCode);
103
 
104
  exit;
models/InstapageCmsPluginSubaccountModel.php CHANGED
@@ -81,7 +81,7 @@ class InstapageCmsPluginSubaccountModel {
81
  if (is_array($tokens) && count($tokens)) {
82
  $headers = array('accountkeys' => InstapageCmsPluginHelper::getAuthHeader($tokens));
83
  $response = json_decode($api->apiCall('page/get-sub-accounts-list', null, $headers));
84
- $subAccounts = @InstapageCmsPluginHelper::getVar($response->data, null);
85
  }
86
 
87
  if ($format == 'json') {
@@ -109,7 +109,7 @@ class InstapageCmsPluginSubaccountModel {
109
  if ($tokens !== null) {
110
  $selectedSubaccounts = $tokens;
111
  } else {
112
- $selectedSubaccounts = InstapageCmsPluginHelper::getVar($post->data->tokens, array());
113
  }
114
 
115
  if (count($selectedSubaccounts)) {
@@ -138,9 +138,21 @@ class InstapageCmsPluginSubaccountModel {
138
  $action[1] = $status == 'connect' ? 'connect' : 'disconnect';
139
 
140
  if (count($selectedSubaccounts) > 1) {
141
- $message = InstapageCmsPluginHelper::getVar($response->message, InstapageCmsPluginConnector::lang('There was an error, selected workspaces are not properly %s app. Try to %s workspaces again.', $action[0], $action[1]));
 
 
 
 
 
 
142
  } else {
143
- $message = InstapageCmsPluginHelper::getVar($response->message, InstapageCmsPluginConnector::lang('There was an error, selected workspace is not properly %s app. Try to %s workspaces again.', $action[0], $action[1]));
 
 
 
 
 
 
144
  }
145
 
146
  echo InstapageCmsPluginHelper::formatJsonMessage($message, 'ERROR');
@@ -150,9 +162,13 @@ class InstapageCmsPluginSubaccountModel {
150
  $action[1] = $status == 'connect' ? 'connected' : 'disconnected';
151
 
152
  if (count($selectedSubaccounts) > 1) {
153
- $message = InstapageCmsPluginHelper::getVar($response->message, InstapageCmsPluginConnector::lang('%s are %s.', $action[0], $action[1]));
 
 
154
  } else {
155
- $message = InstapageCmsPluginHelper::getVar($response->message, InstapageCmsPluginConnector::lang('Selected workspace is %s.', $action[1]));
 
 
156
  }
157
 
158
  echo InstapageCmsPluginHelper::formatJsonMessage($message);
@@ -174,7 +190,7 @@ class InstapageCmsPluginSubaccountModel {
174
  $tokens = array();
175
 
176
  foreach ($subAccounts as $item) {
177
- $tokens[] = InstapageCmsPluginHelper::getVar($item->accountkey, '');
178
  }
179
 
180
  $this->setSubAccountsStatus('disconnect', $tokens, $silent);
81
  if (is_array($tokens) && count($tokens)) {
82
  $headers = array('accountkeys' => InstapageCmsPluginHelper::getAuthHeader($tokens));
83
  $response = json_decode($api->apiCall('page/get-sub-accounts-list', null, $headers));
84
+ $subAccounts = isset($response->data) ? $response->data : null;
85
  }
86
 
87
  if ($format == 'json') {
109
  if ($tokens !== null) {
110
  $selectedSubaccounts = $tokens;
111
  } else {
112
+ $selectedSubaccounts = isset($post->data->tokens) ? $post->data->tokens : array();
113
  }
114
 
115
  if (count($selectedSubaccounts)) {
138
  $action[1] = $status == 'connect' ? 'connect' : 'disconnect';
139
 
140
  if (count($selectedSubaccounts) > 1) {
141
+ $message = isset($response->message)
142
+ ? $response->message
143
+ : InstapageCmsPluginConnector::lang(
144
+ 'There was an error, selected workspaces are not properly %s app. Try to %s workspaces again.',
145
+ $action[0],
146
+ $action[1]
147
+ );
148
  } else {
149
+ $message = isset($response->message)
150
+ ? $response->message
151
+ : InstapageCmsPluginConnector::lang(
152
+ 'There was an error, selected workspace is not properly %s app. Try to %s workspaces again.',
153
+ $action[0],
154
+ $action[1]
155
+ );
156
  }
157
 
158
  echo InstapageCmsPluginHelper::formatJsonMessage($message, 'ERROR');
162
  $action[1] = $status == 'connect' ? 'connected' : 'disconnected';
163
 
164
  if (count($selectedSubaccounts) > 1) {
165
+ $message = isset($response->message)
166
+ ? $response->message
167
+ : InstapageCmsPluginConnector::lang('%s are %s.', $action[0], $action[1]);
168
  } else {
169
+ $message = isset($response->message)
170
+ ? $response->message
171
+ : InstapageCmsPluginConnector::lang('Selected workspace is %s.', $action[1]);
172
  }
173
 
174
  echo InstapageCmsPluginHelper::formatJsonMessage($message);
190
  $tokens = array();
191
 
192
  foreach ($subAccounts as $item) {
193
+ $tokens[] = isset($item->accountkey) ? $item->accountkey : '';
194
  }
195
 
196
  $this->setSubAccountsStatus('disconnect', $tokens, $silent);
views/landingPageAjaxLoader.php DELETED
@@ -1,40 +0,0 @@
1
- <?php
2
- /*
3
- * For pantheon hosting platform (https://pantheon.io/) we need to get content by ajax
4
- * because pantheon replace UTM_ variables value to 'PANTHEON_STRIPPED' and redirect the page.
5
- * Thanks to this solution all UTM_ variable are sent to instapage api.platform
6
- */
7
- ?>
8
-
9
- <html>
10
- <script id='b64-replace' type="text/javascript">
11
- (function () {
12
- var query = [];
13
- var searchArray = document.location.search.replace('?', '').split('&');
14
- var url = document.location.origin + document.location.pathname + '?b64=';
15
- var i;
16
-
17
- for (i = 0; i < searchArray.length; i++) {
18
- if (searchArray[i].indexOf("PANTHEON_STRIPPED") === -1) {
19
- query.push(searchArray[i]);
20
- }
21
- }
22
- if (window.XMLHttpRequest) {
23
- var xhReq = new XMLHttpRequest();
24
- } else {
25
- var xhReq = new ActiveXObject("Microsoft.XMLHTTP");
26
- }
27
-
28
- xhReq.open('GET', url + window.btoa(query.join('&')), false);
29
- xhReq.setRequestHeader("X-Requested-With", "XMLHttpRequest");
30
- xhReq.send();
31
-
32
- document.open();
33
- document.write(xhReq.responseText);
34
- document.close();
35
- document.getElementById("b64-replace").remove();
36
- })();
37
- </script>
38
- <body>
39
- </body>
40
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
views/settings.php CHANGED
@@ -112,6 +112,15 @@
112
  </div>
113
 
114
  <form class="c-section l-space-tertiary">
 
 
 
 
 
 
 
 
 
115
  <div class="cross-origin-form ui-section ">
116
  <h3 class="ui-subtitle"><?php echo InstapageCmsPluginConnector::lang('Cross-origin proxy services'); ?></h3>
117
  <label class="c-mark">
112
  </div>
113
 
114
  <form class="c-section l-space-tertiary">
115
+ <div class="cross-origin-form ui-section ">
116
+ <h3 class="ui-subtitle"><?php echo InstapageCmsPluginConnector::lang('Secure communication'); ?></h3>
117
+ <label class="c-mark">
118
+ <input class="c-mark__input" data-bind="checked: config.ssl, click: autoSaveConfig" type="checkbox" >
119
+ <i class="c-mark__icon c-mark__icon--checkbox material-icons"><?php echo InstapageCmsPluginConnector::lang('check'); ?></i>
120
+ <span class="c-mark__label"><?php echo InstapageCmsPluginConnector::lang('Use HTTPS protocol to communicate with Instapage services. Please note that TLS 1.2 or higher must be used during cURL calls and it requires proper cURL and OpenSSL packages to be installed. Make sure that your pages are still accessible after enabling this option.'); ?></span>
121
+ </label>
122
+ </div>
123
+
124
  <div class="cross-origin-form ui-section ">
125
  <h3 class="ui-subtitle"><?php echo InstapageCmsPluginConnector::lang('Cross-origin proxy services'); ?></h3>
126
  <label class="c-mark">