forked from wpsharks/s2member
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paths2-server-scanner.php
3155 lines (2832 loc) · 172 KB
/
s2-server-scanner.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* Extended Dependency Utilities.
*
* @note Replicate into `[...-]check-my-server.php`;
* or any other file loading this as class: ``websharks_core_v3_deps_x__check_my_server``.
*
* This class MUST remain PHP v5.2 compatible. No namespace, and do NOT extend the framework.
* This class MUST be capable of running with or without WordPress. Possibly in a stand-alone file as class: ``websharks_core_v3_deps_x__check_my_server``.
* We should run a ``check()`` automatically, when loaded in a stand-alone file as class: ``websharks_core_v3_deps_x__check_my_server``.
*
* Copyright: © 2012 (coded in the USA)
* {@link http://www.websharks-inc.com/ WebSharks™}
*
* @author Jason Caldwell
* @package WebSharks\Core
* @since 120318
*/
if(basename(__FILE__) !== 'deps-x.php'
&& class_exists('websharks_core_v3_deps_x__check_my_server')
) // Stand-alone file as class: ``websharks_core_v3_deps_x__check_my_server``.
{
/**
* @var string Plugin name.
*/
define('___CHECK_MY_SERVER__PLUGIN_NAME', 's2Member');
/**
* @var string Plugin directory names (comma-delimited).
*/
define('___CHECK_MY_SERVER__PLUGIN_DIR_NAMES', 's2member,s2member-pro');
/**
* @var websharks_core_v3_deps_x $websharks_core_v3_deps_x__check_my_server
* @noinspection PhpUndefinedClassInspection / Well aware of this.
*/
$websharks_core_v3_deps_x__check_my_server = new websharks_core_v3_deps_x__check_my_server();
/**
* Attempt to load WordPress.
*/
if(!defined('WPINC')) // Try to load the closest WordPress installation.
if(($___WP_LOAD = $websharks_core_v3_deps_x__check_my_server->get_wp_load()))
include_once $___WP_LOAD;
/**
* Run automatic ``check()``.
*/
$websharks_core_v3_deps_x__check_my_server->check();
}
else if(!defined('WPINC')) // Require WordPress.
exit('Do NOT access this file directly.');
/**
* Extended Dependency Utilities.
*
* @note Replicate into `[...-]check-my-server.php`;
* or any other file loading this as class: ``websharks_core_v3_deps_x__check_my_server``.
*
* @note This class name should be suffixed with `__check_my_server`, when running stand-alone.
*
* @package WebSharks\Core
* @since 120318
*/
class websharks_core_v3_deps_x__check_my_server // See also: `deps.php`.
{
/**
* @var array A static cache (for all instances).
*/
public static $info_cache = array();
/**
* Holds ``check()`` method return value.
*
* @var array|boolean|null Defaults to a NULL value.
*/
public $check = NULL;
/**
* Default plugin name to use.
*
* @var string A generic default value.
*/
public $default_plugin_name = 'WebSharks™ Core';
/**
* Default plugin directory names (comma-delimited).
*
* @var string A generic default value.
*/
public $default_plugin_dir_names = 'websharks-core-v3';
/**
* Holds original arguments to ``check()``.
*
* @note This helps auto-fix routines, which need additional functionality.
*
* @var array Original arguments to ``check()``.
*/
public $auto_fix_orig_check_args = array();
/**
* Checks if all dependencies can be satisfied.
* Also runs a deep scan to identify common problems/conflicts/issues.
* Also returns details regarding tests that passed successfully.
*
* @note This docBlock originates in file `deps-x.php`.
* We maintain the master in `deps-x.php`, and it's copied into `deps.php`.
* Also replicates into `[...-]check-my-server.php`, or any stand-alone file loaded as class:
* ``websharks_core_v3_deps_x__check_my_server``.
*
* @param string $plugin_name If empty, defaults to a generic value.
* Name of the plugin that's checking dependencies;
* e.g. the plugin that called this routine.
*
* @param string $plugin_dir_names If empty, defaults to a generic value.
* Name of one or more (comma-delimited) plugin directories associated with dependency scans;
* e.g. directories associated with the plugin that called this routine.
*
* @param boolean $report_notices TRUE by default.
* If FALSE, do NOT report any notices.
*
* @param boolean $report_warnings TRUE by default.
* If FALSE, do NOT report warnings.
*
* @param boolean $check_last_ok TRUE by default. Avoids a re-scan if at all possible.
* If ``$check_last_ok`` is FALSE, it will always force a new full scan.
* Automatically disabled when running in a stand-alone file as class:
* ``websharks_core_v3_deps_x__check_my_server``.
*
* @param boolean $maybe_display_wp_admin_notices TRUE by default. Applies only when running within WordPress.
* If there are issues, we'll automatically enqueue administrative notices to alert the site owner.
* Automatically disabled when running in a stand-alone file as class:
* ``websharks_core_v3_deps_x__check_my_server``.
*
* @return boolean|array TRUE if no `issues`.
* If there ARE `issues`, this returns a multidimensional array (which is NEVER empty).
* A possible FALSE return value (initially), if an auto-fix is being requested by the site owner.
* A possible FALSE return value, if invalid types are passed through arguments list.
*
* @auto-fix A possible FALSE return value, if an auto-fix is being requested (at least, initially).
* If an auto-fix is requested, we check to see if WordPress is loaded up, and if the `init` hook has been fired yet.
* If it has NOT been fired yet, we return FALSE (initially). Then we run this routine again on the `init` hook, with a priority of `1`.
* This allows auto-fix routines to check permissions, and perform other important tasks; with the use of all WordPress functionality.
*
* @note The return value of this function depends heavily on the parameters used to call upon it.
* If it's called with ``$check_last_ok = TRUE`` (the default), there's a good chance it will simply return TRUE.
* That is, if we check a last OK time, and it's valid — a re-scan will NOT be processed; and there are no `issues` to report.
*
* @note This routine also deals with administrative notices in WordPress.
* @note This routine also deals with auto-fix routines in WordPress.
*
* @throws exception If invalid types are passed through arguments list.
*
* @assert ('WebSharks™ Core') === TRUE
*/
public function check($plugin_name = '', $plugin_dir_names = '', $report_notices = TRUE, $report_warnings = TRUE, $check_last_ok = TRUE, $maybe_display_wp_admin_notices = TRUE)
{
// Is WordPress loaded up?
$is_wp_loaded = (defined('WPINC')) ? TRUE : FALSE;
// Cleanup ``$_GET`` vars (if available).
if($is_wp_loaded && !empty($_GET['websharks_core__deps']))
$_g = stripslashes_deep($_GET['websharks_core__deps']);
// Is this an auto-fix request?
if($is_wp_loaded && !empty($_g['auto_fix']) && is_string($_g['auto_fix'])
&& !empty($_g['checksum']) && is_string($_g['checksum']) && $this->verify_checksum($_g['auto_fix'], $_g['checksum'])
) // For further details, please see notes in the docBlock, regarding auto-fix requests.
$is_auto_fix = TRUE;
else $is_auto_fix = FALSE;
// Is this a dismissal request?
if($is_wp_loaded && !empty($_g['dismiss']) && is_string($_g['dismiss'])
&& !empty($_g['checksum']) && is_string($_g['checksum']) && $this->verify_checksum($_g['dismiss'], $_g['checksum'])
) // For further details, please see notes in the docBlock, regarding dismissal requests.
$is_dismissal = TRUE;
else $is_dismissal = FALSE;
// Is this a test email?
if($is_wp_loaded && !empty($_g['test_email']) && is_string($_g['test_email'])
&& !empty($_g['checksum']) && is_string($_g['checksum']) && $this->verify_checksum($_g['test_email'], $_g['checksum'])
) // For further details, please see notes in the docBlock, regarding email requests.
$is_test_email = TRUE;
else $is_test_email = FALSE;
// Is this a test for HTTPS?
if($is_wp_loaded && !empty($_g['test_https']) && is_string($_g['test_https'])
&& !empty($_g['checksum']) && is_string($_g['checksum']) && $this->verify_checksum($_g['test_https'], $_g['checksum'])
) // For further details, please see notes in the docBlock, regarding HTTPS requests.
$is_test_https = TRUE;
else $is_test_https = FALSE;
// If this IS an auto-fix request, should we compact (or extract), the originals?
if($is_wp_loaded && $is_auto_fix) // Yes, this IS an auto-fix request.
if(!did_action('init')) // NOTE: A calling plugin will NOT load up in this case.
{
$this->auto_fix_orig_check_args = compact('plugin_name', 'plugin_dir_names', 'report_notices', 'report_warnings', 'check_last_ok', 'maybe_display_wp_admin_notices');
add_action('init', array($this, 'check'), 1);
return ($this->check = FALSE);
}
else if(!empty($this->auto_fix_orig_check_args) && (func_num_args() === 0 || func_get_args() === array('')))
extract($this->auto_fix_orig_check_args); // Overrides existing argument values.
// Now let's check all argument value types. These MUST be passed in properly, else we trigger an error down below.
if(is_string($plugin_name) && is_string($plugin_dir_names) && is_bool($report_notices) && is_bool($report_warnings) && is_bool($check_last_ok) && is_bool($maybe_display_wp_admin_notices))
{
// Define some other important variables.
$is_check_my_server = (basename(__FILE__) !== 'deps-x.php' && __CLASS__ === 'websharks_core_v3_deps_x__check_my_server') ? TRUE : FALSE;
$check_last_ok = ($is_check_my_server) ? FALSE : $check_last_ok;
$php_version = PHP_VERSION; // Installed PHP version.
global $wp_version; // Global made available by WordPress.
$php_version_required = '5.2'; // Required PHP version.
$wp_version_required = '3.3'; // Required WordPress version.
// Look for possible filtration against this routine.
if($is_wp_loaded && !$is_check_my_server && apply_filters('websharks_core__deps__check_disable', FALSE))
return ($this->check = TRUE); // Return now (DISABLED).
// Has a full scan succeeded in the past?
// If so, is a re-scan necessary? Or is everything still OK?
if($is_wp_loaded && !$is_check_my_server && $check_last_ok
&& is_array($last_ok = get_option('websharks_core__deps__last_ok'))
&& isset($last_ok['websharks_core_v3'], $last_ok['time'], $last_ok['php_version'], $last_ok['wp_version'])
&& $last_ok['time'] >= strtotime('-24 hours') && $last_ok['php_version'] === $php_version && $last_ok['wp_version'] === $wp_version
) // Return TRUE. A re-scan is NOT necessary; everything is still OK.
return ($this->check = TRUE);
// Else we need to run a full scan now.
/*********************************************************************************************/
$issues = $passes = $errors = $warnings = $notices = array();
/*********************************************************************************************/
if(!is_string($plugin_name) || !$plugin_name)
{
if($is_check_my_server && defined('___CHECK_MY_SERVER__PLUGIN_NAME') && ___CHECK_MY_SERVER__PLUGIN_NAME)
$plugin_name = ___CHECK_MY_SERVER__PLUGIN_NAME;
else if($is_check_my_server && preg_match('/^(?P<prefix>.+)-check-my-server\.php$/i', basename(__FILE__), $_file))
$plugin_name = preg_replace('/[_\-]+/i', ' ', $_file['prefix']).'™';
else $plugin_name = $this->default_plugin_name;
unset($_file); // A little housekeeping.
}
/*********************************************************************************************/
if(!is_string($plugin_dir_names) || !$plugin_dir_names)
{
if($is_check_my_server && defined('___CHECK_MY_SERVER__PLUGIN_DIR_NAMES') && ___CHECK_MY_SERVER__PLUGIN_DIR_NAMES)
$plugin_dir_names = ___CHECK_MY_SERVER__PLUGIN_DIR_NAMES;
else if($is_check_my_server && preg_match('/^(?P<prefix>.+)-check-my-server\.php$/i', basename(__FILE__), $_file))
$plugin_dir_names = strtolower(preg_replace('/[_\-]+/i', '-', $_file['prefix']));
else $plugin_dir_names = $this->default_plugin_dir_names;
unset($_file); // A little housekeeping.
}
/*********************************************************************************************/
if(version_compare($php_version, $php_version_required, '<'))
{
$errors[] = array(
'title' => self::i18n('PHP Version'),
'message' => sprintf(
self::i18n(
'PHP v%1$s (or higher) is required to run %2$s.'.
' You are currently running PHP <code>v%3$s</code>. Please upgrade.'
), htmlspecialchars($php_version_required), htmlspecialchars($plugin_name), htmlspecialchars($php_version)
)
);
}
else // Pass on this check.
{
$passes[] = array(
'title' => self::i18n('PHP Version'),
'message' => sprintf(
self::i18n(
'You are currently running PHP <code>%1$s</code> (which is fine).'.
' Minimum required version is: <code>%2$s</code>.'
), htmlspecialchars($php_version), htmlspecialchars($php_version_required)
)
);
}
/*********************************************************************************************/
if($is_wp_loaded && version_compare($wp_version, $wp_version_required, '<'))
{
$errors[] = array(
'title' => self::i18n('WordPress Version'),
'message' => sprintf(
self::i18n(
'WordPress v%1$s (or higher) is required to run %2$s.'.
' You are currently running WordPress <code>v%3$s</code>. Please <a href="%4$s">upgrade</a>.'
), htmlspecialchars($wp_version_required), htmlspecialchars($plugin_name), htmlspecialchars($wp_version), esc_attr(admin_url('/update-core.php'))
)
);
}
else if($is_wp_loaded) // Pass on this check.
{
$passes[] = array(
'title' => self::i18n('WordPress Version'),
'message' => sprintf(
self::i18n(
'You are currently running WordPress <code>%1$s</code> (which is fine).'.
' Minimum required version is: <code>%2$s</code>'
), htmlspecialchars($wp_version), htmlspecialchars($wp_version_required)
)
);
}
/*********************************************************************************************/
if(!extension_loaded('mbstring')) // Multibyte extension for PHP.
{
$errors[] = array(
'title' => self::i18n('Multibyte String Extension'),
'message' => sprintf(
self::i18n(
'Missing PHP extension. %1$s needs the <a href="http://www.php.net/manual/en/book.mbstring.php" target="_blank" rel="xlink">mbstring</a> extension for PHP.'.
' This will add multibyte support to your installation of PHP, allowing UTF-8 character conversion.'.
' Please consult with your web hosting company about this message.'
), htmlspecialchars($plugin_name)
)
);
}
else // Pass on this check.
{
$passes[] = array(
'title' => self::i18n('Multibyte String Extension'),
'message' => sprintf(
self::i18n(
'The <a href="http://www.php.net/manual/en/book.mbstring.php" target="_blank" rel="xlink">mbstring</a> extension is installed.'.
' Your server supports UTF-8 character conversion.'
), NULL
)
);
}
/*********************************************************************************************/
if(!extension_loaded('zlib')) // ZLib extension for PHP (GZIP).
{
$errors[] = array(
'title' => self::i18n('ZLib Extension (GZIP)'),
'message' => sprintf(
self::i18n(
'Missing ZLib extension. %1$s needs the <a href="http://www.php.net/manual/en/book.zlib.php" target="_blank" rel="xlink">zlib</a> extension for PHP.'.
' This will add GZIP support to your installation of PHP, allowing your installation to read/write GZIP compressed files.'.
' Please consult with your web hosting company about this message.'
), htmlspecialchars($plugin_name)
)
);
}
else // Pass on this check.
{
$passes[] = array(
'title' => self::i18n('ZLib Extension (GZIP)'),
'message' => sprintf(
self::i18n(
'The <a href="http://www.php.net/manual/en/book.zlib.php" target="_blank" rel="xlink">zlib</a> extension is installed.'.
' Your server supports GZIP compression.'
), NULL
)
);
}
/*********************************************************************************************/
if(!extension_loaded('hash')) // Hash extension for PHP (enabled by default, make sure it was NOT disabled).
{
$errors[] = array(
'title' => self::i18n('Default Hash Extension'),
'message' => sprintf(
self::i18n(
'Missing Hash extension. %1$s needs the <a href="http://www.php.net/manual/en/book.hash.php" target="_blank" rel="xlink">Hash</a> extension for PHP.'.
' This will add message digest support to your installation of PHP, and allows for direct or incremental processing of arbitrary length messages using a variety of hashing algorithms.'.
' Note, this extension should have been enabled with just a default installation of PHP.'.
' Please consult with your web hosting company about this message.'
), htmlspecialchars($plugin_name)
)
);
}
else // Pass on this check.
{
$passes[] = array(
'title' => self::i18n('Default Hash Extension'),
'message' => sprintf(
self::i18n(
'The <a href="http://www.php.net/manual/en/book.hash.php" target="_blank" rel="xlink">Hash</a> extension is installed.'.
' Comes with every installation of PHP. Your server supports message digests.'
), NULL
)
);
}
/*********************************************************************************************/
if(!extension_loaded('xml')) // XML extension for PHP (enabled by default, make sure it was NOT disabled).
{
$errors[] = array(
'title' => self::i18n('Default XML Parser Extension'),
'message' => sprintf(
self::i18n(
'Missing XML Parser extension. %1$s needs the <a href="http://www.php.net/manual/en/book.xml.php" target="_blank" rel="xlink">XML Parser</a> extension for PHP.'.
' This will add XML support to your installation of PHP, and allows for the creation of XML parsers/events.'.
' Note, this extension should have been enabled with just a default installation of PHP.'.
' Please consult with your web hosting company about this message.'
), htmlspecialchars($plugin_name)
)
);
}
else // Pass on this check.
{
$passes[] = array(
'title' => self::i18n('Default XML Parser Extension'),
'message' => sprintf(
self::i18n(
'The <a href="http://www.php.net/manual/en/book.xml.php" target="_blank" rel="xlink">XML Parser</a> extension is installed.'.
' Comes with every installation of PHP. Your server supports XML parsing.'
), NULL
)
);
}
/*********************************************************************************************/
if(!extension_loaded('libxml')) // libXML extension for PHP (enabled by default, make sure it was NOT disabled).
{
$errors[] = array(
'title' => self::i18n('Default libXML Extension'),
'message' => sprintf(
self::i18n(
'Missing libXML extension. %1$s needs the <a href="http://php.net/manual/en/book.libxml.php" target="_blank" rel="xlink">libXML</a> extension for PHP.'.
' This will add XML support to your installation of PHP. This is a requirement for other extensions, such as SimpleXML and SOAP.'.
' Note, this extension should have been enabled with just a default installation of PHP.'.
' Please consult with your web hosting company about this message.'
), htmlspecialchars($plugin_name)
)
);
}
else // Pass on this check.
{
$passes[] = array(
'title' => self::i18n('Default libXML Extension'),
'message' => sprintf(
self::i18n(
'The <a href="http://php.net/manual/en/book.libxml.php" target="_blank" rel="xlink">libXML</a> extension is installed.'.
' Comes with every installation of PHP. Your server supports this important dependency.'
), NULL
)
);
}
/*********************************************************************************************/
if(!extension_loaded('simplexml')) // Simple XML extension for PHP (enabled by default, make sure it was NOT disabled).
{
$errors[] = array(
'title' => self::i18n('Default Simple XML Extension'),
'message' => sprintf(
self::i18n(
'Missing Simple XML extension. %1$s needs the <a href="http://www.php.net/manual/en/book.simplexml.php" target="_blank" rel="xlink">Simple XML</a> extension for PHP.'.
' This will add XML support to your installation of PHP, and allows for the conversion of XML documents to PHP objects.'.
' Note, this extension should have been enabled with just a default installation of PHP.'.
' Please consult with your web hosting company about this message.'
), htmlspecialchars($plugin_name)
)
);
}
else // Pass on this check.
{
$passes[] = array(
'title' => self::i18n('Default Simple XML Extension'),
'message' => sprintf(
self::i18n(
'The <a href="http://www.php.net/manual/en/book.simplexml.php" target="_blank" rel="xlink">Simple XML</a> extension is installed.'.
' Comes with every installation of PHP. Your server can convert XML into PHP objects.'
), NULL
)
);
}
/*********************************************************************************************/
if(!extension_loaded('xmlreader')) // XML Reader extension for PHP (enabled by default, make sure it was NOT disabled).
{
$errors[] = array(
'title' => self::i18n('Default XML Reader Extension'),
'message' => sprintf(
self::i18n(
'Missing XML Reader extension. %1$s needs the <a href="http://www.php.net/manual/en/book.xmlreader.php" target="_blank" rel="xlink">XML Reader</a> extension for PHP.'.
' This will add XML support to your installation of PHP, and allows for the reading of XML documents.'.
' Note, this extension should have been enabled with just a default installation of PHP.'.
' Please consult with your web hosting company about this message.'
), htmlspecialchars($plugin_name)
)
);
}
else // Pass on this check.
{
$passes[] = array(
'title' => self::i18n('Default XML Reader Extension'),
'message' => sprintf(
self::i18n(
'The <a href="http://www.php.net/manual/en/book.xmlreader.php" target="_blank" rel="xlink">XML Reader</a> extension is installed.'.
' Comes with every installation of PHP. Your server has the ability to read XML documents.'
), NULL
)
);
}
/*********************************************************************************************/
if(!extension_loaded('xmlwriter')) // XML Writer extension for PHP (enabled by default, make sure it was NOT disabled).
{
$errors[] = array(
'title' => self::i18n('Default XML Writer Extension'),
'message' => sprintf(
self::i18n(
'Missing XML Writer extension. %1$s needs the <a href="http://www.php.net/manual/en/book.xmlwriter.php" target="_blank" rel="xlink">XML Writer</a> extension for PHP.'.
' This will add XML support to your installation of PHP, and allows for the creation of XML documents.'.
' Note, this extension should have been enabled with just a default installation of PHP.'.
' Please consult with your web hosting company about this message.'
), htmlspecialchars($plugin_name)
)
);
}
else // Pass on this check.
{
$passes[] = array(
'title' => self::i18n('Default XML Writer Extension'),
'message' => sprintf(
self::i18n(
'The <a href="http://www.php.net/manual/en/book.xmlwriter.php" target="_blank" rel="xlink">XML Writer</a> extension is installed.'.
' Comes with every installation of PHP. Your server has the ability to write XML documents.'
), NULL
)
);
}
/*********************************************************************************************/
if(!extension_loaded('dom')) // DOM extension for PHP (enabled by default, make sure it was NOT disabled).
{
$errors[] = array(
'title' => self::i18n('Default DOM Extension'),
'message' => sprintf(
self::i18n(
'Missing DOM extension. %1$s needs the <a href="http://php.net/manual/en/book.dom.php" target="_blank" rel="xlink">DOM</a> extension for PHP.'.
' This will add Document Object Model support to your installation of PHP, allowing XML documents to be traversed easily.'.
' Note, this extension should have been enabled with just a default installation of PHP.'.
' Please consult with your web hosting company about this message.'
), htmlspecialchars($plugin_name)
)
);
}
else // Pass on this check.
{
$passes[] = array(
'title' => self::i18n('Default DOM Extension'),
'message' => sprintf(
self::i18n(
'The <a href="http://php.net/manual/en/book.dom.php" target="_blank" rel="xlink">DOM</a> extension is installed.'.
' Comes with every installation of PHP. Your server supports XML document traversal.'
), NULL
)
);
}
/*********************************************************************************************/
if(!extension_loaded('session')) // Sessions extension for PHP (enabled by default, make sure it was NOT disabled).
{
$errors[] = array(
'title' => self::i18n('Default Sessions Extension'),
'message' => sprintf(
self::i18n(
'Missing Sessions extension. %1$s needs the <a href="http://www.php.net/manual/en/book.session.php" target="_blank" rel="xlink">Sessions</a> extension for PHP.'.
' This will add sessioning support to your installation of PHP, allowing read/write access to session data.'.
' Note, this extension should have been enabled with just a default installation of PHP.'.
' Please consult with your web hosting company about this message.'
), htmlspecialchars($plugin_name)
)
);
}
else // Pass on this check.
{
$passes[] = array(
'title' => self::i18n('Default Sessions Extension'),
'message' => sprintf(
self::i18n(
'The <a href="http://www.php.net/manual/en/book.session.php" target="_blank" rel="xlink">Sessions</a> extension is installed.'.
' Comes with every installation of PHP. Your server allows read/write access to session data.'
), NULL
)
);
}
/*********************************************************************************************/
if(!extension_loaded('mysql')) // MySQL extension for PHP.
{
$errors[] = array(
'title' => self::i18n('MySQL Database Extension'),
'message' => sprintf(
self::i18n(
'Missing MySQL extension. %1$s needs the <a href="http://php.net/manual/en/book.mysql.php" target="_blank" rel="xlink">MySQL</a> extension for PHP.'.
' This will add MySQL support to your installation of PHP, allowing MySQL database communication.'.
' Please consult with your web hosting company about this message.'
), htmlspecialchars($plugin_name)
)
);
}
else // Pass on this check.
{
$passes[] = array(
'title' => self::i18n('MySQL Database Extension'),
'message' => sprintf(
self::i18n(
'The <a href="http://php.net/manual/en/book.mysql.php" target="_blank" rel="xlink">MySQL</a> extension is installed.'.
' Your server supports MySQL database communication.'
), NULL
)
);
}
/*********************************************************************************************/
if(!extension_loaded('mcrypt')) // Mcrypt extension for PHP.
{
$errors[] = array(
'title' => self::i18n('Mcrypt/Encryption Extension'),
'message' => sprintf(
self::i18n(
'Missing Mcrypt extension. %1$s needs the <a href="http://php.net/manual/en/book.mcrypt.php" target="_blank" rel="xlink">Mcrypt</a> extension for PHP.'.
' This will add encryption support to your installation of PHP, with a variety of block algorithms; such as DES, TripleDES, and Blowfish.'.
' Please consult with your web hosting company about this message.'
), htmlspecialchars($plugin_name)
)
);
}
else // Pass on this check.
{
$passes[] = array(
'title' => self::i18n('Mcrypt/Encryption Extension'),
'message' => sprintf(
self::i18n(
'The <a href="http://php.net/manual/en/book.mcrypt.php" target="_blank" rel="xlink">Mcrypt</a> extension is installed.'.
' Your server supports advanced data encryption.'
), NULL
)
);
}
/*********************************************************************************************/
if(!extension_loaded('json')) // JSON extension for PHP (enabled by default, make sure it was NOT disabled).
{
$errors[] = array(
'title' => self::i18n('Default JSON Extension'),
'message' => sprintf(
self::i18n(
'Missing JSON extension. %1$s needs the <a href="http://php.net/manual/en/book.json.php" target="_blank" rel="xlink">JSON</a> extension for PHP.'.
' This will add JSON support to your installation of PHP, a standard JavaScript Object Notation (JSON) data-interchange format.'.
' Note, this extension should have been enabled with just a default installation of PHP.'.
' Please consult with your web hosting company about this message.'
), htmlspecialchars($plugin_name)
)
);
}
else // Pass on this check.
{
$passes[] = array(
'title' => self::i18n('Default JSON Extension'),
'message' => sprintf(
self::i18n(
'The <a href="http://php.net/manual/en/book.json.php" target="_blank" rel="xlink">JSON</a> extension is installed.'.
' Comes with every installation of PHP. Your server supports JavaScript object notation.'
), NULL
)
);
}
/*********************************************************************************************/
$gd_info = ($this->is_function_possible('gd_info')) ? gd_info() : array();
if(!extension_loaded('gd')) // GD extension for PHP.
{
$errors[] = array(
'title' => self::i18n('GD Image Extension'),
'message' => sprintf(
self::i18n(
'Missing GD Image extension. %1$s needs the <a href="http://php.net/manual/en/book.image.php" target="_blank" rel="xlink">GD Image</a> extension for PHP.'.
' This will add image creation support to your installation of PHP, so that images can be generated dynamically.'.
' Please consult with your web hosting company about this message.'
), htmlspecialchars($plugin_name)
)
);
}
else if(empty($gd_info['FreeType Support'])) // FreeType Support?
{
$errors[] = array(
'title' => self::i18n('GD Image Extension (FreeType Support)'),
'message' => sprintf(
self::i18n(
'Missing FreeType library for GD Image extension. %1$s needs the <a href="http://php.net/manual/en/book.image.php" target="_blank" rel="xlink">GD Image</a> extension for PHP, with the FreeType library also.'.
' This will add image creation support to your installation of PHP, so that images can be generated dynamically. FreeType makes it possible for fonts to be used in image generation.'.
' Please consult with your web hosting company about this message.'
), htmlspecialchars($plugin_name)
)
);
}
else if(empty($gd_info['JPG Support']) && empty($gd_info['JPEG Support'])) // JPEG Support?
{
$errors[] = array(
'title' => self::i18n('GD Image Extension (JPEG Support)'),
'message' => sprintf(
self::i18n(
'Missing JPEG support for GD Image extension. %1$s needs the <a href="http://php.net/manual/en/book.image.php" target="_blank" rel="xlink">GD Image</a> extension for PHP, with JPEG support enabled.'.
' This will add JPEG image creation support to your installation of PHP, so that JPEG images can be generated dynamically.'.
' Please consult with your web hosting company about this message.'
), htmlspecialchars($plugin_name)
)
);
}
else if(empty($gd_info['PNG Support'])) // PNG Support?
{
$errors[] = array(
'title' => self::i18n('GD Image Extension (PNG Support)'),
'message' => sprintf(
self::i18n(
'Missing PNG support for GD Image extension. %1$s needs the <a href="http://php.net/manual/en/book.image.php" target="_blank" rel="xlink">GD Image</a> extension for PHP, with PNG support enabled.'.
' This will add PNG image creation support to your installation of PHP, so that PNG images can be generated dynamically.'.
' Please consult with your web hosting company about this message.'
), htmlspecialchars($plugin_name)
)
);
}
else // Pass on this check.
{
$passes[] = array(
'title' => self::i18n('GD Image Extension (JPEG/PNG/FreeType)'),
'message' => sprintf(
self::i18n(
'The <a href="http://php.net/manual/en/book.image.php" target="_blank" rel="xlink">GD Image</a> extension is installed.'.
' Your server supports dynamic image creation.'
), NULL
)
);
}
/*********************************************************************************************/
if(version_compare($php_version_required, '5.3', '>=') && !extension_loaded('fileinfo'))
{
$errors[] = array(
'title' => self::i18n('Default Fileinfo Extension'),
'message' => sprintf(
self::i18n(
'Missing Fileinfo extension. %1$s needs the <a href="http://php.net/manual/en/book.fileinfo.php" target="_blank" rel="xlink">Fileinfo</a> extension for PHP.'.
' This will add MIME type support to your installation of PHP, allowing PHP applications to detect a files\' MIME type.'.
' Note, this extension should have been enabled with just a default installation of PHP v5.3+.'.
' Please consult with your web hosting company about this message.'
), htmlspecialchars($plugin_name)
)
);
}
else // Pass on this check.
{
$passes[] = array(
'title' => self::i18n('Default Fileinfo Extension'),
'message' => sprintf(
self::i18n(
'The <a href="http://php.net/manual/en/book.fileinfo.php" target="_blank" rel="xlink">Fileinfo</a> extension is installed.'.
' Comes with every installation of PHP 5.3+. Your server supports MIME type detection.'
), NULL
)
);
}
/*********************************************************************************************/
if(!extension_loaded('ctype')) // Ctype extension for PHP (enabled by default, make sure it was NOT disabled).
{
$errors[] = array(
'title' => self::i18n('Default Ctype Extension'),
'message' => sprintf(
self::i18n(
'Missing Ctype extension. %1$s needs the <a href="http://php.net/manual/en/book.ctype.php" target="_blank" rel="xlink">CType</a> extension for PHP.'.
' This will add character class support to your installation of PHP, allowing detection of certain types of characters, based on locale.'.
' Note, this extension should have been enabled with just a default installation of PHP.'.
' Please consult with your web hosting company about this message.'
), htmlspecialchars($plugin_name)
)
);
}
else // Pass on this check.
{
$passes[] = array(
'title' => self::i18n('Default Ctype Extension'),
'message' => sprintf(
self::i18n(
'The <a href="http://php.net/manual/en/book.ctype.php" target="_blank" rel="xlink">Ctype</a> extension is installed.'.
' Comes with every installation of PHP. Your server supports character class detection.'
), NULL
)
);
}
/*********************************************************************************************/
if(!$this->is_function_possible('eval')) // Hosting company disabled this?
{
$errors[] = array(
'title' => self::i18n('PHP <code>eval()</code> Function'),
'message' => sprintf(
self::i18n(
'Missing PHP function. %1$s needs the PHP <a href="http://php.net/manual/en/function.eval.php" target="_blank" rel="xlink">eval()</a> function.'.
' Please check with your hosting provider to resolve this issue and have PHP <code>eval()</code> enabled.'.
' Note... the use of <code>eval()</code>, is limited to areas where it is absolutely necessary to achieve a desired functionality.'.
' For instance, where PHP code is supplied by a site owner (or by their developer) to achieve advanced customization through a UI panel. This can be evaluated at runtime to allow for the inclusion of PHP conditionals or dynamic values.'.
' In cases such as these, the PHP <code>eval()</code> function serves a valid purpose. This does NOT introduce a vulnerability, because the code being evaluated has actually been introduced by the site owner (e.g. the code can be trusted in this case).'
), htmlspecialchars($plugin_name)
)
);
}
else // Pass on this check.
{
$passes[] = array(
'title' => self::i18n('PHP <code>eval()</code> Function'),
'message' => sprintf(
self::i18n(
'The <a href="http://php.net/manual/en/function.eval.php" target="_blank" rel="xlink">eval()</a> function is available.'
), NULL
)
);
}
/*********************************************************************************************/
if(!($ini_get_possible = $this->is_function_possible('ini_get'))) // Hosting company disabled this?
{
$errors[] = array(
'title' => self::i18n('PHP <code>ini_get()</code> Function'),
'message' => sprintf(
self::i18n(
'The PHP function <code>ini_get()</code> is NOT available. Perhaps disabled by your hosting company. You will need <code>ini_get()</code> to run %1$s.'.
' Please consult with your hosting company about this message. See also, <a href="http://php.net/manual/en/function.ini-get.php" target="_blank" rel="xlink">the PHP documentation for ini_get()</a>.'.
' <strong>Also, please NOTE...</strong> other spurious errors/warnings/notices may follow as a result of <code>ini_get()</code> being inaccessible. <strong>Please fix this problem first!</strong>'
), htmlspecialchars($plugin_name)
)
);
}
else // Pass on this check.
{
$passes[] = array(
'title' => self::i18n('PHP <code>ini_get()</code> Function'),
'message' => sprintf(
self::i18n(
'The <a href="http://php.net/manual/en/function.ini-get.php" target="_blank" rel="xlink">ini_get()</a> function is available.'
), NULL
)
);
}
/*********************************************************************************************/
if(!filter_var(ini_get('short_open_tag'), FILTER_VALIDATE_BOOLEAN))
{
$errors[] = array(
'title' => self::i18n('PHP Short Open Tag: <code><?</code>'),
'message' => sprintf(
self::i18n(
'PHP <code>v%1$s</code> MUST be configured with <code>short_open_tag=on</code> in your <a href="http://www.php.net/manual/en/ini.core.php#ini.short-open-tag" target="_blank" rel="xlink">php.ini</a> file.'.
' Please check <a href="http://www.php.net/manual/en/ini.core.php#ini.short-open-tag" target="_blank" rel="xlink">this article</a> for further details.'.
' Or, consult with your web hosting company about this message. You are currently running PHP with <code>short_open_tag=off</code>.'
), htmlspecialchars($php_version)
)
);
}
else // Pass on this check.
{
$passes[] = array(
'title' => self::i18n('PHP Short Open Tag: <code><?</code>'),
'message' => sprintf(
self::i18n(
'You are currently running PHP <code>v%1$s</code>, with <code>short_open_tag=on</code>. So you\'re good here.'
), htmlspecialchars($php_version)
)
);
}
/*********************************************************************************************/
if(version_compare($php_version, '5.4', '<') && !filter_var(ini_get('short_open_tag'), FILTER_VALIDATE_BOOLEAN))
{
$errors[] = array(
'title' => self::i18n('PHP Echo Tag: <code><?=?></code>'),
'message' => sprintf(
self::i18n(
'PHP <code>v%1$s</code> MUST be configured with <code>short_open_tag=on</code> in your <a href="http://www.php.net/manual/en/ini.core.php#ini.short-open-tag" target="_blank" rel="xlink">php.ini</a> file.'.
' Please check <a href="http://www.php.net/manual/en/ini.core.php#ini.short-open-tag" target="_blank" rel="xlink">this article</a> for further details.'.
' Or, consult with your web hosting company about this message. You are currently running PHP with <code>short_open_tag=off</code>.'
), htmlspecialchars($php_version)
)
);
}
else if(version_compare($php_version, '5.4', '>='))
{
$passes[] = array(
'title' => self::i18n('PHP Echo Tag: <code><?=?></code>'),
'message' => sprintf(
self::i18n(
'PHP <code>v%1$s</code> supports the echo tag (<code><?=?></code>) at all times. So you\'re good here.'
), htmlspecialchars($php_version)
)
);
}
else // Pass on this check.
{
$passes[] = array(
'title' => self::i18n('PHP Echo Tag: <code><?=?></code>'),
'message' => sprintf(
self::i18n(
'You are currently running PHP <code>v%1$s</code>, with <code>short_open_tag=on</code>. Support for PHP echo tags (<code><?=?></code>) is enabled.'
), htmlspecialchars($php_version)
)
);
}
/*********************************************************************************************/
$curl_possible = (extension_loaded('curl') && $this->is_function_possible('curl_init') && $this->is_function_possible('curl_version')) ? TRUE : FALSE;
$curl_over_ssl_possible = ($curl_possible && is_array($curl_version = curl_version()) && $curl_version['features'] & CURL_VERSION_SSL) ? TRUE : FALSE;
$fopen_url_possible = ($ini_get_possible && filter_var(ini_get('allow_url_fopen'), FILTER_VALIDATE_BOOLEAN)) ? TRUE : FALSE;
$fopen_url_over_ssl_possible = ($fopen_url_possible && extension_loaded('openssl')) ? TRUE : FALSE;
$curl_over_ssl_test_success = $fopen_url_over_ssl_test_success = FALSE;
$curl_fopen_ssl_test_url = 'https://www.websharks-inc.com/robots.txt';
$curl_fopen_ssl_test_url_return_string_frag = 'user-agent';
$curl_localhost_test_success = $fopen_url_localhost_test_success = FALSE;
$curl_fopen_localhost_test_url = 'http://'.$_SERVER['HTTP_HOST'];
$curl_fopen_localhost_test_url_return_string_frag = 'html';
if($curl_possible && $curl_over_ssl_possible)
{
if(is_resource($_curl_test_resource = curl_init()))
{
curl_setopt_array(
$_curl_test_resource, array(
CURLOPT_CONNECTTIMEOUT => 5, CURLOPT_TIMEOUT => 5,
CURLOPT_URL => $curl_fopen_ssl_test_url, CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_FAILONERROR => TRUE, CURLOPT_FORBID_REUSE => TRUE, CURLOPT_SSL_VERIFYPEER => FALSE
)
);
if(stripos((string)curl_exec($_curl_test_resource), $curl_fopen_ssl_test_url_return_string_frag) !== FALSE)
$curl_over_ssl_test_success = TRUE;
curl_close($_curl_test_resource);
}
unset($_curl_test_resource); // Housekeeping.
if(is_resource($_curl_test_resource = curl_init()))
{
curl_setopt_array(
$_curl_test_resource, array(
CURLOPT_CONNECTTIMEOUT => 5, CURLOPT_TIMEOUT => 5,
CURLOPT_URL => $curl_fopen_localhost_test_url, CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_FAILONERROR => TRUE, CURLOPT_FORBID_REUSE => TRUE, CURLOPT_SSL_VERIFYPEER => FALSE
)
);
if(stripos((string)curl_exec($_curl_test_resource), $curl_fopen_localhost_test_url_return_string_frag) !== FALSE)
$curl_localhost_test_success = TRUE;
curl_close($_curl_test_resource);
}
unset($_curl_test_resource); // Housekeeping.
}
if($fopen_url_possible && $fopen_url_over_ssl_possible)
{